Skip to content

Validation

Validation runs before submit. Built-in fields validate their own constraints, such as text length, number ranges, category membership, date bounds, and series ordering.

Use form validators for cross-field rules:

validators: [
({ values }) => {
if (Number(values.min) > Number(values.max)) {
return { fields: { max: ["Max must be greater than min."] } };
}
},
];

Validators can return:

Return valueMeaning
voidNo issue.
string[]Form-level errors.
{ form, fields }Form and field errors.

Hooks can observe validation:

hooks: {
beforeValidate({ values }) {},
afterValidate({ result }) {},
}

If a validator reports an unknown field id, MLForm throws instead of silently dropping the error.