Spec-Zone.ru › Valibot

url

Creates an URL validation action.

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

Generics

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

Parameters

  • message TMessage

Explanation

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

The value is checked with the URL parser. This check is not perfect. For example, values like "abc:1234" are accepted.

If you only need to validate an ASCII domain name, consider the domain action.

Returns

  • Action UrlAction<TInput, TMessage>

Examples

The following examples show how url can be used.

URL schema

Schema to validate an URL.

const UrlSchema = v.pipe(
  v.string(),
  v.nonEmpty('Please enter your url.'),
  v.url('The url is badly formatted.'),
  v.endsWith('.com', 'Only ".com" domains are allowed.')
);

Related

The following APIs can be combined with url.

Schemas

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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