UNPKG

@modular-forms/react

Version:

The modular and type-safe form library for React

19 lines (18 loc) 342 B
/** * Creates a validation functions that validates a URL. * * @param error The error message. * * @returns A validation function. */ export function url(error) { return (value) => { try { value && new URL(value); return ''; } catch (_) { return error; } }; }