Url

February 3, 2026 · View on GitHub

  • Url()

Validates whether the input is a valid URL in a popular internet format.

v::url()->assert('http://example.com');
// Validation passes successfully

v::url()->assert('https://www.youtube.com/watch?v=6FOUqQt3Kg0');
// Validation passes successfully

v::url()->assert('ldap://[::1]');
// Validation passes successfully

v::url()->assert('mailto:john.doe@example.com');
// Validation passes successfully

v::url()->assert('http://example.this_top_level_domain_does_not_exist');
// → "http://example.this_top_level_domain_does_not_exist" must be a URL

This validator uses [Ip][Ip.md], [Domain][Domain.md] and [Email][Email.md] internally, activating them depending on the input scheme.

If you want to restrict URLs to a specific scheme, you can use [StartsWith][StartsWith.md] or any other verifier:

v::startsWith('http')->url()->assert('http://example.com');
// Validation passes successfully

v::startsWith('http')->url()->assert('ftp://example.com');
// → "ftp://example.com" must start with "http"

Templates

Url::TEMPLATE_STANDARD

ModeTemplate
default{{subject}} must be a URL
inverted{{subject}} must not be a URL

Template placeholders

PlaceholderDescription
subjectThe validated input or the custom validator name (if specified).

Categorization

  • Internet

Changelog

VersionDescription
3.0.0Templates changed
3.0.0Stricter use of Ip, Domain and Email internally. Select schemes only.
0.8.0Created

See Also