Skip to content

uri

Validates that a field contains a valid URL.

Options

OptionTypeDefaultDescription
messagestringlocale defaultCustom error message

Playground

Valid values

ValueNotes
"https://example.com"HTTPS URL
"http://sub.example.co.uk/path?q=1"With subdomain, path, and query
"ftp://files.example.com"FTP URL

Invalid values

ValueReason
"not a url"No protocol
"example.com"Missing protocol
"http://"Missing host

Notes

  • Empty string ("") always returns valid: true — validators only run on non-empty values. Combine with notEmpty to require a value.

Released under the MIT License.