Skip to content

Interface: ValidatorArgs<FieldValueType, ArgsStruct, T>

forms/types/ValidatorArgs.ValidatorArgs

Validator functions are given a single context object argument with the following structure:

Type parameters

Name
FieldValueType
ArgsStruct
T

Properties

args

args: ArgsStruct

The args value will be whatever args are specified to the field upon initialization.

For example, if the fields are specified in this way:

.. code-block:: js

{
  password: {
    value: '',
    validators: [{name: 'length', args: {min: 5, max: 50}}]
  }
  password2: {
    value: '',
    validators: [{name: 'matches', args: {fieldName: 'password'}}],
  },
}

...Then the length validator args for password will be {min: 5, max: 50} and the matches validator args for password2 will be {fieldName: 'password'}.

Defined in

src/base/forms/types/ValidatorArgs.ts:28


fieldName

fieldName: keyof T

The name of the field to be validated.

Defined in

src/base/forms/types/ValidatorArgs.ts:45


formState

formState: FormState<T>

The current raw state of the form module in its entirety.

Defined in

src/base/forms/types/ValidatorArgs.ts:49


signal

signal: AbortSignal

An AbortSignal <https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal>_ connected to the current validation attempt. This might be used if the field is updated and a new attempt will replace the current one, or if the user submits the form before validation completes.

Hand this signal to any network requests you perform to ensure that the request is appropriately aborted if the validation attempt is aborted.

Defined in

src/base/forms/types/ValidatorArgs.ts:37


value

value: FieldValueType

The value of the field to be validated.

Defined in

src/base/forms/types/ValidatorArgs.ts:41