email
The string looks like an email: something@something.something, no spaces.
Signature
ts
function email(msg?: Message): Action<string>Parameters
| Parameter | Type | Description |
|---|---|---|
msg | Message | Custom error message. A string with {params} or a function |
Error codes
| Code | When | Default message |
|---|---|---|
email | Does not look like an email | Invalid email |
You can change the texts: see Messages & i18n.
Notes
- The check is intentionally simple: strict email regexes often reject real addresses. The only way to know an address exists is to send an email.
- Usually combined with
trimandtoLowerCaseto store emails consistently.
Example
Email
ts
pipe(string(), trim(), toLowerCase(), email())See also
- pattern — custom format check
- checkAsync — check that the email is not taken