respect-validation/docs/validators/Url.md
Alexandre Gomes Gaigalas 16148e9593 Standardize and improve validation message templates
- Remove redundant "valid" prefix:
   Date, DateTime, DateTimeDiff, Domain, Email, Iban, Imei, Ip, Isbn, Json, LanguageCode, LeapDate, LeapYear, Luhn, MacAddress, NfeAccessKey, Nif, Nip, Pesel, Phone, Pis, PolishIdCard, PostalCode, Roman, Slug, Tld, Url, Uuid, Version.

 - Remove redundant "value" suffix
   ArrayVal, BoolVal, Countable, FloatVal, IntVal, IterableVal, NumericVal, ScalarVal, StringVal.

 - Standardize "consist only of" phrasing
   Alnum, Alpha, Cntrl, Consonant, Digit, Graph, Lowercase, Printable, Punct, Space, Spaced, Uppercase, Vowel, Xdigit.

 - Improve file accessibility messages
   Directory, Executable, File, Image, Readable, SymbolicLink, Writable.

 - Improve grammar and article usage
   CreditCard, Extension, Mimetype, Regex, Size.
2026-02-03 19:58:55 +00:00

2.3 KiB

Url

  • 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

Mode Template
default {{subject}} must be a URL
inverted {{subject}} must not be a URL

Template placeholders

Placeholder Description
subject The validated input or the custom validator name (if specified).

Categorization

  • Internet

Changelog

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

See Also