Resolver

A resolver provided by common-resolver accepts a schema from a validation library and returns a Resolver object.

The Resolver object exposes a validate method that returns one of two states depending on the validation result. If validation succeeds, valid is true and error is null; if validation fails, valid is false and the error object contains the fields and related information.

The error object mirrors the original data structure and is represented as nested entries so you can easily locate errors for specific fields. This consistent interface allows you to handle errors the same way regardless of which validation library you use, making it highly effective for form validation and data integrity checks.

The error object conforms to the CRES type. This type mirrors the original data shape but makes all properties optional and represents each value as a string message. The structure is applied recursively so nested objects retain the same pattern, which makes it straightforward to identify which field in a complex object caused the error.

Resolver - Using Validation Adapters | ilokesto - React Library Collection