Home > @polyspec/crudui-validator > validate
validate() function
Validate data against a CRUDUI spec. The spec may carry $ref/$patch; they are expanded first via the compose pass. An unresolved composition throws ComposeLoadError (caller distinguishes a LOAD failure from valid:false).
Signature:
export declare function validate(spec: Record<string, unknown>, data: unknown, options?: ValidateOptions): ValidationResult;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
spec |
Record<string, unknown> |
a CRUDUI root spec (a group with |
|
data |
unknown |
the form data to validate; root and group data are objects and repeated data is a keyed object. |
|
options |
(Optional) compose loader / file set / basepath. |
Returns:
{ valid, errors, hidden }.
Exceptions
ComposeLoadError when composition cannot be resolved.
FormInputError when submitted data has the wrong shape.