Skip to content

@opencraft/providence


Interface: ValidatorArgs\<FieldValueType, ArgsStruct, T>

Defined in: forms/types/ValidatorArgs.ts:6

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

Type Parameters

FieldValueType

FieldValueType

ArgsStruct

ArgsStruct

T

T

Properties

args

args: ArgsStruct

Defined in: forms/types/ValidatorArgs.ts:28

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

Text Only
{
  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'}.


fieldName

fieldName: keyof T

Defined in: forms/types/ValidatorArgs.ts:45

The name of the field to be validated.


formState

formState: FormState\<T>

Defined in: forms/types/ValidatorArgs.ts:49

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


signal

signal: AbortSignal

Defined in: forms/types/ValidatorArgs.ts:37

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.


value

value: FieldValueType

Defined in: forms/types/ValidatorArgs.ts:41

The value of the field to be validated.