Skip to content
Playground
You're on the v1 docs. Go to v2.

Validator

When the form is submitted, the form data is validated to conform to the given JSON schema.

interface Validator {
isValid(
schema: SchemaDefinition,
rootSchema: Schema,
formData: SchemaValue | undefined
): boolean;
reset(): void;
}
interface ValidationError<E> {
instanceId: string;
propertyTitle: string;
message: string;
error: E;
}
type MaybePromise<T> = T | Promise<T>;
interface FormValidator2<E = unknown> extends Validator {
/**
* Full form validation
*
* Essentially this is the `formData is T` check, but since `T` doesn't
* extend `SchemaValue`, we don't declare this as a type guard.
*/
validateFormData(
rootSchema: Schema,
formData: SchemaValue | undefined,
signal: AbortSignal
): MaybePromise<ValidationError<E>[]>;
/**
* Individual field validation
*/
validateFieldData(
field: Config,
fieldData: SchemaValue | undefined,
signal: AbortSignal
): MaybePromise<ValidationError<E>[]>;
}