easy-forms
Validation

Overview

How validation works — typed built-ins, custom and async validators, messages, and modes.

Validation is declared on each question's validators object. The available rules are narrowed by the field's value type, so you can only use rules that make sense for the control.

{
	key: 'email',
	label: 'Email',
	control: 'email',
	validators: {
		required: true,
		email: true,
		minLength: 5,
	},
}

The pipeline

When a field validates, rules run in a defined order, short-circuiting on the first error:

  1. Synchronous built-ins (required, minLength, email, min, …)
  2. Synchronous custom validators
  3. Asynchronous custom validators (token-guarded against races)

Hidden fields short-circuit entirely — a field hidden by a dependency is not validated and not included in the submitted values.

In this section