Interface ValidationPlugin<Options>

The plugin that enables a field value validation.

interface ValidationPlugin<Options> {
    isInvalid?: boolean;
    isValidating: boolean;
    validation: null | Validation<any>;
    validator: Validator<any, any>;
    abortValidation(): void;
    on(eventType, subscriber): Unsubscribe;
    on(eventType, subscriber): Unsubscribe;
    validate(options?): boolean;
    validateAsync(options?): Promise<boolean>;
}

Type Parameters

  • Options = any

    Options passed to the validator.

Properties

isInvalid?: boolean

true if this field has an invalid value, or false otherwise.

isValidating: boolean

true if the validation is pending, or false otherwise.

validation: null | Validation<any>

The pending validation, or null if there's no pending validation.

validator: Validator<any, any>

The validator to which the field value validation is delegated.

Methods

  • Aborts the async validation of the validation root field associated with this field. No-op if there's no pending validation.

    Returns void

  • Subscribes to the start of the validation. Event.data carries the validation that is going to start.

    Parameters

    • eventType: "validation:start"

      The type of the event.

    • subscriber: Subscriber<Validation<any>, any>

      The subscriber that would be triggered.

    Returns Unsubscribe

    The callback to unsubscribe the subscriber.

  • Subscribes to the end of the validation. Check isInvalid to detect the actual validity status. Event.data carries the validation that has ended.

    Parameters

    • eventType: "validation:end"

      The type of the event.

    • subscriber: Subscriber<Validation<any>, any>

      The subscriber that would be triggered.

    Returns Unsubscribe

    The callback to unsubscribe the subscriber.

  • Triggers a synchronous field validation.

    If this field is currently being validated then the validation is aborted at current validation root.

    Field.isTransient Transient descendants of this field are excluded from validation.

    Parameters

    Returns boolean

    true if the field is valid, or false if this field or any of it descendants have an associated error.

  • Triggers an asynchronous field validation.

    If this field is currently being validated then the validation is aborted at current validation root.

    Field.isTransient Transient descendants of this field are excluded from validation.

    Parameters

    Returns Promise<boolean>

    true if the field is valid, or false if this field or any of it descendants have an associated error.