Class Ok

Wraps a dictionary of validators and allows binding/applying it to DOM elements.

Hierarchy

  • Ok

Constructors

Methods

Constructors

  • Creates a new instance.

    Parameters

    • validators: Record<string, Validator>

      Object containing the validators to use. Each key corresponds to the key used when referencing the validator from the HTML attribute. The value contains the validator to apply. See Validator for details.

    Returns Ok

Methods

  • Binds a validate event handler to a validatable element.

    Parameters

    • element: ValidatableElement

      ValidatableElement to bind an event to.

    • eventType: string = "input"

      Event type to bind. Recommended is either 'input' or 'change'. Defaults to 'input'.

    Returns void

  • Validates an input element and returns if it was valid. Usually called through bind.

    Returns

    validity of the element.

    Parameters

    • element: ValidatableElement

      ValidatableElement to validate.

    • Optional e: Event

      Optional event that triggered validation.

    Returns boolean

Generated using TypeDoc