UNPKG

@modular-forms/qwik

Version:

The modular and type-safe form library for Qwik

15 lines (14 loc) 407 B
import { $ } from '@builder.io/qwik'; /** * Creates a validation functions that validates a email. * * @param error The error message. * * @returns A validation function. */ export function email(error) { return $((value) => value && !/^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i.test(value) ? error : ''); }