rfcEmail
Creates a RFC email validation action.
const Action = v.rfcEmail<TInput, TMessage>(message);
Generics
TInputextends stringTMessageextends ErrorMessage<RfcEmailIssue<TInput>> | undefined
Parameters
messageTMessage
Explanation
With rfcEmail you can validate the formatting of a string. If the input is not an email, you can use message to customize the error message.
This validation action uses the regex defined by the HTML Living Standard for
<input type="email">, which covers most of RFC 5322 but not all of it. For example, quoted local parts and comments are not supported. If you are interested in an action that only validates common email addresses, please use the
Returns
ActionRfcEmailAction<TInput, TMessage>
Examples
The following examples show how rfcEmail can be used.
Email schema
Schema to validate an email.
const EmailSchema = v.pipe(
v.string(),
v.nonEmpty('Please enter your email.'),
v.rfcEmail('The email is badly formatted.'),
v.maxLength(30, 'Your email is too long.')
);
Related
The following APIs can be combined with rfcEmail.
Schemas
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/rfcEmail/