Interface Validator

Index

Properties

Methods

Properties

public errorList: ErrorListItem[]

public errorMap: ErrorDictionary

public settings: ValidationOptions

Methods

public addClassRules(name: string, rules: Object)

Add a compound class method - useful to refactor common combinations of rules into a single class.

Parameters

  • name: string

    The name of the class rule to add

  • rules: Object

    The compound rules

public addClassRules(rules: Object)

Add a compound class method - useful to refactor common combinations of rules into a single class.

Parameters

  • rules: Object

    A map of className-rules pairs

public addMethod(name: string, method: (value: any, element: any, params: any) => any, message?: any)

Add a custom validation method. It must consist of a name (must be a legal javascript identifier), a javascript based function and a default string message.

Parameters

  • name: string

    The name of the method used to identify it and referencing it; this must be a valid JavaScript identifier

  • method: (value: any, element: any, params: any) => any

    The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters.

  • message?: any optional

public element(element: any): boolean

Validates a single element, returns true if it is valid, false otherwise.

Parameters

  • element: any

    An element to validate, must be inside the validated form. eg "#myselect"

Returns

boolean

public form(): boolean

Validates the form, returns true if it is valid, false otherwise.

Returns

boolean

public format(template: string, arguments?: Array<string>): string

Replaces {n} placeholders with arguments.

Parameters

  • template: string

    The string to format.

  • arguments?: Array<string> optional

Returns

string

public hideErrors()

public numberOfInvalids(): number

Returns the number of invalid fields.

Returns

number

public resetForm()

Resets the controlled form.

public setDefaults(defaults: ValidationOptions)

Modify default settings for validation.

Parameters

public showErrors(errors: any)

Show the specified messages.

Parameters

  • errors: any

    One or more key/value pairs of input names and messages.

public size(): number

Returns

number

public valid(): boolean

Returns

boolean