UNPKG

@matthew.ngo/reform

Version:

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

27 lines (26 loc) 857 B
import { FormGroup } from '../../form/form-groups'; import { YupContextReturn } from './types'; /** * Hook for managing Yup validation context in Reform forms * * @template T - The type of form data * @param groups - The form groups * @returns Object with Yup context utilities * * @example * // Basic usage * const reform = useReform(config); * const yupContext = useYupContext(reform.getGroups()); * * // Create a schema with context * const schema = yupContext.createSchemaWithContext(baseSchema); * * // Add additional context data * useEffect(() => { * yupContext.updateContextData({ * currentUser: user, * permissions: userPermissions * }); * }, [user, userPermissions]); */ export declare const useYupContext: <T extends Record<string, any>>(groups: FormGroup<T>[]) => YupContextReturn<T>;