@modular-forms/qwik
Version:
The modular and type-safe form library for Qwik
20 lines (19 loc) • 383 B
JavaScript
import { $ } from '@builder.io/qwik';
/**
* 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;
}
});
}