PHPackages                             frostbitten/flexible-url - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. frostbitten/flexible-url

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

frostbitten/flexible-url
========================

A Laravel validation rule that accepts URLs without a scheme and normalizes them to https://

1.0.0(3mo ago)05MITPHPPHP ^8.2

Since Feb 11Pushed 3mo agoCompare

[ Source](https://github.com/snoe-labs/flexible-url)[ Packagist](https://packagist.org/packages/frostbitten/flexible-url)[ RSS](/packages/frostbitten-flexible-url/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

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
------------

[](#installation)

```
composer require frostbitten/flexible-url
```

Usage
-----

[](#usage)

Use it as a drop-in replacement for Laravel's `url` rule:

```
use Frostbitten\FlexibleUrl\FlexibleUrl;

public function rules(): array
{
    return [
        'website' => ['nullable', new FlexibleUrl],
    ];
}
```

When a user submits `example.com`, the rule:

1. Prepends `https://` to get `https://example.com`
2. Validates the normalized URL using Laravel's built-in `url` rule
3. Updates the validator data so `$request->validated()` returns the normalized value

URLs that already include `http://` or `https://` are left untouched.

How normalization works
-----------------------

[](#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

[](#after-normalization-callback)

For cases where you need additional control, pass a callback:

```
new FlexibleUrl(function (string $attribute, string $normalizedValue) {
    // e.g. update a Livewire property
    $this->$attribute = $normalizedValue;
})
```

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
------------

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance82

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

96d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bfec8cc0f9d7704c4c6072bb4983d433a95a84b8a575d667cb51679c11db5ef1?d=identicon)[\_\_gregory](/maintainers/__gregory)

---

Top Contributors

[![gpluess](https://avatars.githubusercontent.com/u/598360?v=4)](https://github.com/gpluess "gpluess (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/frostbitten-flexible-url/health.svg)

```
[![Health](https://phpackages.com/badges/frostbitten-flexible-url/health.svg)](https://phpackages.com/packages/frostbitten-flexible-url)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[illuminate/validation

The Illuminate Validation package.

18936.7M1.4k](/packages/illuminate-validation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
