Skip to main content

onValidation

Fires when the form's validation result changes - from valid to invalid, invalid to valid, or when the set of field errors changes.

Usage

onValidation?: (ev: {
errors: Record<string, { errorType: string }> | null;
values: Record<string, any>;
}) => void;
FieldTypeDescription
errorsRecord<string, { errorType: string }> | nullMap of field key to error, or null when all values are valid.
valuesRecord<string, any>Current values snapshot.

errorType is "required" for an empty required field or "validation" for a failed custom rule.

Example

import { Editor } from "@svar-ui/react-editor";

function onValidation(ev) {
if (ev.errors) {
for (const key in ev.errors) {
console.log(`${key}: ${ev.errors[key].errorType}`);
}
}
}

<Editor items={items} values={values} onValidation={onValidation} />;