/** * A simple IDictionary */ export interface StringKeyValuePair { [key: string]: string; } /** * A simple logging interface that mirrors the Console object. */ export interface Logger { log(message: string, ...args: any[]): void; warn(message: string, ...args: any[]): void; } /** * An `HTMLElement` that can be validated (`input`, `select`, `textarea`). */ export type ValidatableElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; /** * Checks if `element` is validatable (`input`, `select`, `textarea`). * @param element The element to check. * @returns `true` if validatable, otherwise `false`. */ export declare const isValidatable: (element: Node) => element is ValidatableElement; /** * Parameters passed into validation providers from the element attributes. * error property is read from data-val-[Provider Name] attribute. * params property is populated from data-val-[Provider Name]-[Parameter Name] attributes. */ export interface ValidationDirectiveBindings { error: string; params: StringKeyValuePair; } /** * A key-value pair describing what validations to enforce to an input element, with respective parameters. */ export type ValidationDirective = { [key: string]: ValidationDirectiveBindings; }; /** * Validation plugin signature with multitype return. * Boolean return signifies the validation result, which uses the default validation error message read from the element attribute. * String return signifies failed validation, which then will be used as the validation error message. * Promise return signifies asynchronous plugin behavior, with same behavior as Boolean or String. */ export type ValidationProvider = (value: string, element: ValidatableElement, params: StringKeyValuePair) => boolean | string | Promise; /** * Callback to receive the result of validating a form. */ export type ValidatedCallback = (success: boolean) => void; /** * Contains default implementations for ASP.NET Core MVC validation attributes. */ export declare class MvcValidationProviders { /** * Validates whether the input has a value. */ required: ValidationProvider; /** * Validates whether the input value satisfies the length contstraint. */ stringLength: ValidationProvider; /** * Validates whether the input value is equal to another input value. */ compare: ValidationProvider; /** * Validates whether the input value is a number within a given range. */ range: ValidationProvider; /** * Validates whether the input value satisfies a regular expression pattern. */ regex: ValidationProvider; /** * Validates whether the input value is an email in accordance to RFC822 specification, with a top level domain. */ email: ValidationProvider; /** * Validates whether the input value is a credit card number, with Luhn's Algorithm. */ creditcard: ValidationProvider; /** * Validates whether the input value is a URL. */ url: ValidationProvider; /** * Validates whether the input value is a phone number. */ phone: ValidationProvider; /** * Asynchronously validates the input value to a JSON GET API endpoint. */ remote: ValidationProvider; } /** * Configuration for @type {ValidationService}. */ export interface ValidationServiceOptions { watch: boolean; root: ParentNode; addNoValidate: boolean; } /** * Responsible for managing the DOM elements and running the validation providers. */ export declare class ValidationService { /** * A key-value collection of loaded validation plugins. */ private providers; /** * A key-value collection of elements for displaying validation messages for an input (by DOM ID). */ private messageFor; /** * A list of managed elements, each having a randomly assigned unique identifier (UID). */ private elementUIDs; /** * A key-value collection of UID to Element for quick lookup. */ private elementByUID; /** * A key-value collection of input UIDs for a
UID. */ private formInputs; /** * A key-value map for input UID to its validator factory. */ private validators; /** * A key-value map for form UID to its trigger element (submit event for ). */ private formEvents; /** * A key-value map for element UID to its trigger element (input event for