@jay-js/system
Version:
A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.
20 lines (19 loc) • 947 B
TypeScript
import type { YupObjectSchema } from "../types/external-types.js";
import type { TResolver } from "../types.js";
/**
* A resolver function for validating form values using a Yup schema.
*
* @template T - The type of the form values.
* @param {ObjectSchema<any>} schema - The Yup schema to validate against.
* @returns {TResolver<T>} - A resolver function that validates the form values and returns validation errors, if any.
*
* The resolver function takes the form values and an optional field name as input.
* If a field name is provided, it validates only that field. Otherwise, it validates the entire form.
*
* The function returns an object containing an array of errors. Each error includes:
* - `path`: The path of the field with the error.
* - `message`: The error message.
*
* If no errors are found, the `errors` array will be empty.
*/
export declare function yupResolver<T>(schema: YupObjectSchema<any>): TResolver<T>;