UNPKG

@modular-forms/react

Version:

The modular and type-safe form library for React

15 lines (14 loc) 377 B
/** * Creates a custom validation function. * * @param requirement The validation function. * @param error The error message. * * @returns A validation function. */ export function custom(requirement, error) { return async (value) => (Array.isArray(value) ? value.length : value || value === 0) && !(await requirement(value)) ? error : ''; }