UNPKG

@matthew.ngo/reform

Version:

A flexible and powerful React form management library with advanced validation, state observation, and multi-group support

32 lines (31 loc) 1.09 kB
import { DynamicSchemaConfig } from "./types"; import { ReformReturn } from "../../../types"; /** * Hook wrapper for dynamic schema validation in Reform forms * * @template T - The type of form data * @param reform - Reform hook return value * @param config - Configuration for dynamic schema validation * @returns Dynamic schema validation state and methods * * @example * // Basic usage * const reform = useReform<UserForm>({...}); * const dynamicValidation = useReformDynamicValidation(reform, { * validations: [ * { * field: "email", * rules: [ * { * validate: (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value), * message: "Invalid email format" * } * ] * } * ] * }); * * // Validate a field * const result = dynamicValidation.validateField(0, "email", "test@example.com"); */ export declare const useReformDynamicValidation: <T extends Record<string, any>>(reform: ReformReturn<T>, config: DynamicSchemaConfig<T>) => import("./types").DynamicSchemaReturn<T>;