PHPackages                             fxmonster/validation - 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. fxmonster/validation

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

fxmonster/validation
====================

Additional Validator Functions for the Laravel Framework

0237PHP

Since Nov 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/fxmonster/validation)[ Packagist](https://packagist.org/packages/fxmonster/validation)[ RSS](/packages/fxmonster-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Intervention Validation
=======================

[](#intervention-validation)

Intervention Validation is an extension library for Laravel's own validation system. The package adds rules to validate data like IBAN, BIC, ISBN, creditcard numbers and more.

[![Latest Version](https://camo.githubusercontent.com/7b038900ef054ff515ead7cef1ad12706a4456ff30400a562912c20bcd41e840/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e74657276656e74696f6e2f76616c69646174696f6e2e737667)](https://packagist.org/packages/intervention/validation)[![build](https://github.com/Intervention/validation/workflows/build/badge.svg)](https://github.com/Intervention/validation/workflows/build/badge.svg)[![Monthly Downloads](https://camo.githubusercontent.com/14648712dc828cbbfc729cbbc8f972856e64f352ad4d1ef13c0e8d4b346b5e87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f696e74657276656e74696f6e2f76616c69646174696f6e2e737667)](https://packagist.org/packages/intervention/validation/stats)

Installation
------------

[](#installation)

You can install this package quick and easy with Composer.

Require the package via Composer:

```
$ composer require intervention/validation

```

### Laravel integration (optional)

[](#laravel-integration-optional)

The Validation library is built to work with the Laravel Framework (&gt;=5.5). It comes with a service provider, which will be discovered automatically and registers the validation rules into your installation.

Usage
-----

[](#usage)

```
use Intervention\Validation\Validator;
use Intervention\Validation\Rules\HexColor;
use Intervention\Validation\Exception\ValidationException;

// create validator (for HexColor)
$validator = new Validator(new HexColor);

// validate against given values
$valid = $validator->validate('#ccc'); // true
$valid = $validator->validate('www'); // false

// change the validation rule
$validator->setRule(new Domainname);

// now validate new rule domainname
$valid = $validator->validate('foo.com'); // true
$valid = $validator->validate('?'); // false

// validator can also throw exceptions on invalid data.
// just call assert() instead of validate().
try {
    $validator->assert('foobar');
} catch (ValidationException $e) {
    echo $e->getMessage();
}
```

Static Usage
------------

[](#static-usage)

```
use Intervention\Validation\Validator;
use Intervention\Validation\Rules\HexColor;
use Intervention\Validation\Exception\ValidationException;

// create validator statically
$valid = Validator::make(new HexColor)->validate('ccc'); // true
$valid = Validator::make(new HexColor)->validate('#www'); // false

// throw exceptions on invalid data instead of returning boolean
try {
    Validator::make(new HexColor)->assert('www');
} catch (ValidationException $e) {
    echo $e->getMessage();
}
```

Static dynamic call Usage
-------------------------

[](#static-dynamic-call-usage)

```
use Intervention\Validation\Validator;
use Intervention\Validation\Rules\HexColor;
use Intervention\Validation\Exception\ValidationException;

// call validation rule directly via static method
$valid = Validator::isHexColor('#ccc'); // true
$valid = Validator::isHexColor('#www'); // false

// throw exceptions on invalid data
try {
    Validator::assertHexColor('foo');
} catch (ValidationException $e) {
    echo $e->getMessage();
}
```

Usage with Laravel
------------------

[](#usage-with-laravel)

The installed package provides additional `validation rules` including their error messages.

```
use Illuminate\Support\Facades\Validator;
use Intervention\Validation\Rules\Creditcard;

$validator = Validator::make($request->all(), [
    'color' => 'required|hexcolor',
    'number' => 'iban',
    'ccnumber' => new Creditcard(), // passing rules as objects is also possible
]);
```

### Changing the error messages:

[](#changing-the-error-messages)

Add the corresponding key to `/resources/lang//validation.php` like this:

```
// example
'iban' => 'Please enter IBAN number!',
```

Or add your custom messages directly to the validator like [described in the docs](https://laravel.com/docs/6.x/validation#custom-error-messages).

Available Rules
---------------

[](#available-rules)

The following validation rules are available.

### base64 (Intervention\\Validation\\Rules\\Base64)

[](#base64-interventionvalidationrulesbase64)

Checks if given value is [Base64 encoded](https://en.wikipedia.org/wiki/Base64).

### bic (Intervention\\Validation\\Rules\\Bic)

[](#bic-interventionvalidationrulesbic)

Checks for a valid [Business Identifier Code](https://en.wikipedia.org/wiki/ISO_9362) (BIC).

### camelcase (Intervention\\Validation\\Rules\\CamelCase)

[](#camelcase-interventionvalidationrulescamelcase)

The given field must be a formated in [Camel case](https://en.wikipedia.org/wiki/Camel_case).

### cidr (Intervention\\Validation\\Rules\\Cidr)

[](#cidr-interventionvalidationrulescidr)

Check if the value is a [Classless Inter-Domain Routing](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) notation (CIDR).

### creditcard (Intervention\\Validation\\Rules\\Creditcard)

[](#creditcard-interventionvalidationrulescreditcard)

The given field must be a valid [creditcard number](https://en.wikipedia.org/wiki/Payment_card_number).

### data url (Intervention\\Validation\\Rules\\DataUrl)

[](#data-url-interventionvalidationrulesdataurl)

The given field must be a valid [data url](https://en.wikipedia.org/wiki/Data_URI_scheme).

### domainname (Intervention\\Validation\\Rules\\Domainname)

[](#domainname-interventionvalidationrulesdomainname)

The given field must be a well formed [domainname](https://en.wikipedia.org/wiki/Domain_name).

### ean (Intervention\\Validation\\Rules\\Ean)

[](#ean-interventionvalidationrulesean)

Checks for a valid [European Article Number](https://en.wikipedia.org/wiki/International_Article_Number) (EAN-8 and EAN-13).

### gtin (Intervention\\Validation\\Rules\\Gtin)

[](#gtin-interventionvalidationrulesgtin)

Checks for a valid [Global Trade Item Number](https://en.wikipedia.org/wiki/Global_Trade_Item_Number) (GTIN-8, GTIN-12, GTIN-13 or GTIN-14).

### hexcolor (Intervention\\Validation\\Rules\\HexColor)

[](#hexcolor-interventionvalidationruleshexcolor)

The field under validation must be a valid [hexadecimal color code](https://en.wikipedia.org/wiki/Web_colors).

### htmlclean (Intervention\\Validation\\Rules\\HtmlClean)

[](#htmlclean-interventionvalidationruleshtmlclean)

The field under validation must be free of any html code.

### iban (Intervention\\Validation\\Rules\\Iban)

[](#iban-interventionvalidationrulesiban)

Checks for a valid [International Bank Account Number](https://en.wikipedia.org/wiki/International_Bank_Account_Number) (IBAN).

### imei (Intervention\\Validation\\Rules\\Imei)

[](#imei-interventionvalidationrulesimei)

The given field must be a [International Mobile Equipment Identity](https://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity) (IMEI).

### isbn (Intervention\\Validation\\Rules\\Isbn)

[](#isbn-interventionvalidationrulesisbn)

The field under validation must be a valid [International Standard Book Number](https://en.wikipedia.org/wiki/International_Standard_Book_Number) (ISBN).

### isin (Intervention\\Validation\\Rules\\Isin)

[](#isin-interventionvalidationrulesisin)

Checks for a valid [International Securities Identification Number](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) (ISIN).

### issn (Intervention\\Validation\\Rules\\Issn)

[](#issn-interventionvalidationrulesissn)

Checks for a valid [International Standard Serial Number](https://en.wikipedia.org/wiki/International_Standard_Serial_Number) (ISSN).

### jwt (Intervention\\Validation\\Rules\\Jwt)

[](#jwt-interventionvalidationrulesjwt)

The given value must be a in format of a [JSON Web Token](https://en.wikipedia.org/wiki/JSON_Web_Token).

### kebabcase (Intervention\\Validation\\Rules\\KebabCase)

[](#kebabcase-interventionvalidationruleskebabcase)

The given value must be formated in [Kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).

### lowercase (Intervention\\Validation\\Rules\\LowerCase)

[](#lowercase-interventionvalidationruleslowercase)

The given value must be all lower case letters.

### luhn (Intervention\\Validation\\Rules\\Luhn)

[](#luhn-interventionvalidationrulesluhn)

The given value must verify against its included [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) check digit.

### macaddress (Intervention\\Validation\\Rules\\MacAddress)

[](#macaddress-interventionvalidationrulesmacaddress)

The field under validation must be a [media access control address](https://en.wikipedia.org/wiki/MAC_address) (MAC address).

### semver (Intervention\\Validation\\Rules\\SemVer)

[](#semver-interventionvalidationrulessemver)

The given field must be a valid version numbers using [Semantic Versioning](https://semver.org/).

### slug (Intervention\\Validation\\Rules\\Slug)

[](#slug-interventionvalidationrulesslug)

The field under validation must be a user- and [SEO-friendly short text](https://en.wikipedia.org/wiki/Clean_URL#Slug).

### snakecase (Intervention\\Validation\\Rules\\SnakeCase)

[](#snakecase-interventionvalidationrulessnakecase)

The field under validation must formated as [Snake case](https://en.wikipedia.org/wiki/Snake_case) text.

### titlecase (Intervention\\Validation\\Rules\\TitleCase)

[](#titlecase-interventionvalidationrulestitlecase)

The field under validation must formated in [Title case](https://en.wikipedia.org/wiki/Title_case).

### ulid (Intervention\\Validation\\Rules\\Ulid)

[](#ulid-interventionvalidationrulesulid)

The given field must be a valid [Universally Unique Lexicographically Sortable Identifier](https://github.com/ulid/spec).

### uppercase (Intervention\\Validation\\Rules\\UpperCase)

[](#uppercase-interventionvalidationrulesuppercase)

The field under validation must be all upper case.

### username (Intervention\\Validation\\Rules\\Username)

[](#username-interventionvalidationrulesusername)

The field under validation must be a valid username with a minimum of 3 characters and maximum of 20 characters. Consisting of alpha-numeric characters, underscores, minus and starting with a alphabetic character. Multiple underscore and minus chars are not allowed. Underscore and minus chars are not allowed at the beginning or end.

License
-------

[](#license)

Intervention Validation is licensed under the [MIT License](http://opensource.org/licenses/MIT).

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd798ef4478ec11bfe6a54f17cd0feca6380d901670e7c44121fb9f5381262b3?d=identicon)[fxmonster](/maintainers/fxmonster)

---

Top Contributors

[![fxmonster](https://avatars.githubusercontent.com/u/13942239?v=4)](https://github.com/fxmonster "fxmonster (2 commits)")

### Embed Badge

![Health badge](/badges/fxmonster-validation/health.svg)

```
[![Health](https://phpackages.com/badges/fxmonster-validation/health.svg)](https://phpackages.com/packages/fxmonster-validation)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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