url
Creates an URL validation action.
const Action = v.url<TInput, TMessage>(message);
Generics
TInputextends stringTMessageextends ErrorMessage<UrlIssue<TInput>> | undefined
Parameters
messageTMessage
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
domainaction.
Returns
ActionUrlAction<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
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/url/