Spec-Zone.ru › Valibot

domain

Creates a domain name validation action.

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

Generics

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

Parameters

  • message TMessage

Explanation

With domain you can validate the formatting of a domain string. If the input is not a valid domain, you can use message to customize the error message.

Validates ASCII domains. Limits: 63 chars per label, 253 chars total. Internationalized domain names (IDNs) are not supported, including Punycode-encoded labels. If you need to validate a full URL (including protocol, path, query, etc.), use the url action.

Returns

  • Action DomainAction<TInput, TMessage>

Examples

The following examples show how domain can be used.

Domain schema

Schema to validate a domain.

const DomainSchema = v.pipe(
  v.string(),
  v.nonEmpty('Please enter your domain.'),
  v.domain('The domain is badly formatted.')
);

Related

The following APIs can be combined with domain.

Schemas

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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