Function signature for validation logic. Validators receive the current field value, runtime options, and field context, and either return a transformed value or throw an error for invalid input.
The type of options passed to the validator
The current value being validated
Configuration options for the validation
Context information about the field being validated
The validated/transformed value or a Promise resolving to it
Should throw an error if validation fails
const minLengthValidator: Validator<{ length: number }> = ( value, { length }, field) => { if (typeof value === 'string' && value.length >= length) { return value } throw new Error(`Minimum length is ${length}`)} Copy
const minLengthValidator: Validator<{ length: number }> = ( value, { length }, field) => { if (typeof value === 'string' && value.length >= length) { return value } throw new Error(`Minimum length is ${length}`)}
Function signature for validation logic. Validators receive the current field value, runtime options, and field context, and either return a transformed value or throw an error for invalid input.