Download the PHP package frostbitten/flexible-url without Composer
On this page you can find all versions of the php package frostbitten/flexible-url. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download frostbitten/flexible-url
More information about frostbitten/flexible-url
Files in frostbitten/flexible-url
Package flexible-url
Short Description A Laravel validation rule that accepts URLs without a scheme and normalizes them to https://
License MIT
Informations about the package flexible-url
Flexible URL
A Laravel validation rule that accepts URLs with or without a scheme. When the scheme is missing, it normalizes the value to https:// automatically.
Users type google.com, not https://google.com. This rule handles that gracefully.
Installation
Usage
Use it as a drop-in replacement for Laravel's url rule:
When a user submits example.com, the rule:
- Prepends
https://to gethttps://example.com - Validates the normalized URL using Laravel's built-in
urlrule - Updates the validator data so
$request->validated()returns the normalized value
URLs that already include http:// or https:// are left untouched.
How normalization works
The normalized value is written back to the validator's internal data via an after callback. This means $validator->validated() (and by extension $request->validated() in Form Requests) returns the normalized URL.
This works in all contexts:
- Form Requests
- Livewire validation
- Manual
Validator::make()calls - Artisan commands
After-normalization callback
For cases where you need additional control, pass a callback:
The callback is only invoked when normalization actually occurs (i.e. a scheme was prepended). It is not called when the URL already has a scheme.
Requirements
- PHP 8.2+
- Laravel 11 or 12
License
MIT
All versions of flexible-url with dependencies
illuminate/contracts Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
illuminate/validation Version ^12.0 || ^13.0