Spec-Zone.ru › Valibot

rfcEmail

Creates a RFC email validation action.

const Action = v.rfcEmail<TInput, TMessage>(message);

Generics

  • TInput extends string
  • TMessage extends ErrorMessage<RfcEmailIssue<TInput>> | undefined

Parameters

  • message TMessage

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 email action instead.

Returns

  • Action RfcEmailAction<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

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/rfcEmail/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API