UNPKG

react-validator-dev

Version:

Real-time error messaging and supports field dependencies React hook for form validation

46 lines (45 loc) 1.11 kB
interface ValidationRule { isRequired?: boolean; maxLength?: number; minLength?: number; excludedCharacters?: string[]; regex?: string | any; alpha?: boolean; email?: boolean; numeric?: boolean; date?: boolean; alphaDash?: boolean; alphaSpace?: boolean; sameAsField?: string; } interface ErrorMessage { isRequired?: string; maxLength?: string; minLength?: string; excludedCharacters?: string; regex?: string; alpha?: string; email?: string; numeric?: string; date?: string; alphaDash?: string; alphaSpace?: string; sameAsField?: string; } interface Validation { rules: { [key: string]: ValidationRule; }; messages?: { [key: string]: ErrorMessage; }; } interface ValidationErrors { errors: Record<string, string>; status: boolean; } declare const useValidation: (data: { fields: Record<string, any>; validation: Validation; }, isMultiple?: boolean, submit?: boolean, debounceDelay?: number, validateAll?: boolean) => ValidationErrors[]; export default useValidation;