Skip to content
PlaygroundForm Builder

Fields

The FieldsValidationMode type controls when field validation is triggered. By default, fields are validated on input and change events.

export type FieldsValidationMode = number;
let iota = 0;
/** Validation is triggered on input event */
export const ON_INPUT = 1 << iota++;
/** Validation is triggered on change event */
export const ON_CHANGE = 1 << iota++;
/** Validation is triggered on blur event */
export const ON_BLUR = 1 << iota++;
/** Validation is triggered on add/remove item in array */
export const ON_ARRAY_CHANGE = 1 << iota++;
/** Validation is triggered on add/remove/rename property in object */
export const ON_OBJECT_CHANGE = 1 << iota++;
/** Validation is not triggered before first change event */
export const AFTER_CHANGED = 1 << iota++;
/** Validation is not triggered before first blur event */
export const AFTER_TOUCHED = 1 << iota++;
/** Validation is not triggered before first form submission */
export const AFTER_SUBMITTED = 1 << iota;

Each field maintains its own state, including validation errors and touched status.

export type FieldState = number;
let iota = 0;
export const FIELD_FOCUSED = 1 << iota++;
export const FIELD_INPUTTED = 1 << iota++;
export const FIELD_CHANGED = 1 << iota++;
export const FIELD_BLURRED = 1 << iota++;
export const FIELD_SUBMITTED = 1 << iota++;
export const FIELD_INTERACTED = (1 << iota) - 1;
export const FIELD_EXPANDED = 1 << iota;