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

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

intervention/validation
=======================

Additional validation rules for the Laravel framework

4.6.2(2mo ago)6826.7M↓21.7%70[2 issues](https://github.com/Intervention/validation/issues)6MITPHPPHP ^8.1CI passing

Since Jan 30Pushed 2mo ago10 watchersCompare

[ Source](https://github.com/Intervention/validation)[ Packagist](https://packagist.org/packages/intervention/validation)[ Docs](https://validation.intervention.io/)[ Fund](https://paypal.me/interventionio)[ GitHub Sponsors](https://github.com/Intervention)[ RSS](/packages/intervention-validation/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (4)Dependencies (12)Versions (106)Used By (6)

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)[![Tests](https://github.com/Intervention/validation/actions/workflows/build.yml/badge.svg)](https://github.com/Intervention/validation/actions/workflows/build.yml)[![Monthly Downloads](https://camo.githubusercontent.com/14648712dc828cbbfc729cbbc8f972856e64f352ad4d1ef13c0e8d4b346b5e87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f696e74657276656e74696f6e2f76616c69646174696f6e2e737667)](https://packagist.org/packages/intervention/validation/stats)[![Support me on Ko-fi](https://raw.githubusercontent.com/Intervention/validation/main/.github/images/support.svg)](https://ko-fi.com/interventionphp)

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

[](#installation)

You can install this package quick and easy with Composer.

Require the package via Composer:

```
$ composer require intervention/validation

```

Laravel integration
-------------------

[](#laravel-integration)

The Validation library is built to work with the Laravel Framework (&gt;=10). It comes with a service provider, which will be discovered automatically and registers the validation rules into your installation. The package provides 37 additional validation rules including multi language error messages, which can be used like Laravel's own validation rules.

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

$validator = Validator::make($request->all(), [
    'color' => new Hexadecimalcolor([3, 6]), // pass rule as object
    'number' => ['required', 'creditcard'], // or pass rule as string
    'name' => 'required|min:3|max:20|username', // combining rules works as well
]);
```

### 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/10.x/validation#manual-customizing-the-error-messages).

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

[](#available-rules)

The following validation rules are available with this package.

### Austrian insurance Number (austrian social security number)

[](#austrian-insurance-number-austrian-social-security-number)

The field under validation must be an [Austrian insurance number](https://de.wikipedia.org/wiki/Sozialversicherungsnummer#%C3%96sterreich)

```
public Intervention\Validation\Rules\AustrianInsuranceNumber::__construct()

```

### Base64 encoded string

[](#base64-encoded-string)

The field under validation must be [Base64 encoded](https://en.wikipedia.org/wiki/Base64).

```
public Intervention\Validation\Rules\Base64::__construct()

```

### Business Identifier Code (BIC)

[](#business-identifier-code-bic)

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

```
public Intervention\Validation\Rules\Bic::__construct()

```

### Camel case string

[](#camel-case-string)

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

```
public Intervention\Validation\Rules\Camelcase::__construct()

```

### Classless Inter-Domain Routing (CIDR)

[](#classless-inter-domain-routing-cidr)

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

```
public Intervention\Validation\Rules\Cidr::__construct()

```

### Creditcard Number

[](#creditcard-number)

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

```
public Intervention\Validation\Rules\Creditcard::__construct()

```

### Data URI scheme

[](#data-uri-scheme)

The field under validation must be a valid [Data URI](https://en.wikipedia.org/wiki/Data_URI_scheme).

```
public Intervention\Validation\Rules\DataUri::__construct(?array $media_types = null)

```

### Domain name

[](#domain-name)

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

```
public Intervention\Validation\Rules\Domainname::__construct()

```

### European Article Number (EAN)

[](#european-article-number-ean)

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

```
public Intervention\Validation\Rules\Ean::__construct(array $lengths = [8, 13])

```

#### Parameters

[](#parameters)

**length**

Optional integer length (8 or 13) to check only for EAN-8 or EAN-13.

### Global Release Identifier (GRid)

[](#global-release-identifier-grid)

The field under validation must be a [Global Release Identifier](https://en.wikipedia.org/wiki/Global_Release_Identifier).

```
public Intervention\Validation\Rules\Grid::__construct()

```

### Global Trade Item Number (GTIN)

[](#global-trade-item-number-gtin)

Checks for a valid [Global Trade Item Number](https://en.wikipedia.org/wiki/Global_Trade_Item_Number).

```
public Intervention\Validation\Rules\Gtin::__construct(array $lengths = [8, 12, 13, 14])

```

#### Parameters

[](#parameters-1)

**length**

Optional array of allowed lengths to check only for certain types (GTIN-8, GTIN-12, GTIN-13 or GTIN-14).

### Hexadecimal color code

[](#hexadecimal-color-code)

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

```
public Intervention\Validation\Rules\Hexadecimalcolor::__construct(array $lengths = [3, 4, 6, 8])

```

#### Parameters

[](#parameters-2)

**length**

Optional length as integer to check only for shorthand (3 or 4 characters) or full hexadecimal (6 or 8 characters) form.

### HSL Color

[](#hsl-color)

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

```
public Intervention\Validation\Rules\Hslcolor::__construct()

```

### HSV Color

[](#hsv-color)

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

```
public Intervention\Validation\Rules\Hsvcolor::__construct()

```

### Text without HTML

[](#text-without-html)

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

```
public Intervention\Validation\Rules\HtmlClean::__construct()

```

### International Bank Account Number (IBAN)

[](#international-bank-account-number-iban)

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

```
public Intervention\Validation\Rules\Iban::__construct()

```

### International Mobile Equipment Identity (IMEI)

[](#international-mobile-equipment-identity-imei)

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

```
public Intervention\Validation\Rules\Imei::__construct()

```

### International Standard Book Number (ISBN)

[](#international-standard-book-number-isbn)

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

```
public Intervention\Validation\Rules\Isbn::__construct(array $lengths = [10, 13])

```

#### Parameters

[](#parameters-3)

**length**

Optional length parameter as integer to check only for ISBN-10 or ISBN-13.

### International Securities Identification Number (ISIN)

[](#international-securities-identification-number-isin)

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

```
public Intervention\Validation\Rules\Isin::__construct()

```

### International Standard Recording Code (ISRC)

[](#international-standard-recording-code-isrc)

The field under validation must be a valid [International Standard Recording Code](https://en.wikipedia.org/wiki/International_Standard_Recording_Code) (ISRC).

```
public Intervention\Validation\Rules\Isrc::__construct()

```

### International Standard Serial Number (ISSN)

[](#international-standard-serial-number-issn)

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

```
public Intervention\Validation\Rules\Issn::__construct()

```

### JSON Web Token (JWT)

[](#json-web-token-jwt)

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

```
public Intervention\Validation\Rules\Jwt::__construct()

```

### Kebab case string

[](#kebab-case-string)

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

```
public Intervention\Validation\Rules\Kebabcase::__construct()

```

### Latitude

[](#latitude)

Checks for a valid geographic [Latitude](https://en.wikipedia.org/wiki/Latitude).

```
public Intervention\Validation\Rules\Latitude::__construct()

```

### Longitude

[](#longitude)

Checks for a valid geographic [Longitude](https://en.wikipedia.org/wiki/Longitude).

```
public Intervention\Validation\Rules\Longitude::__construct()

```

### LatLng

[](#latlng)

Checks for a valid geographic comma separated pair of a [Latitude](https://en.wikipedia.org/wiki/Latitude) and a [Longitude](https://en.wikipedia.org/wiki/Longitude).

```
public Intervention\Validation\Rules\LatLng::__construct()

```

### Lower case string

[](#lower-case-string)

The given value must be all lower case letters.

```
public Intervention\Validation\Rules\Lowercase::__construct()

```

### Luhn algorithm

[](#luhn-algorithm)

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

```
public Intervention\Validation\Rules\Luhn::__construct()

```

### Media (MIME) type

[](#media-mime-type)

Checks for a valid [Mime Type](https://en.wikipedia.org/wiki/Media_type) (Media type).

```
public Intervention\Validation\Rules\MimeType::__construct()

```

### Postal Code

[](#postal-code)

The field under validation must be a [postal code](https://en.wikipedia.org/wiki/Postal_code) of the given country.

```
public Intervention\Validation\Rules\Postalcode::__construct(array $countrycodes = [])

```

#### Parameters

[](#parameters-4)

**countrycode**

Country code in [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) format.

### Postal Code (static instantiation)

[](#postal-code-static-instantiation)

```
public static Intervention\Validation\Rules\Postalcode::countrycode(array $countrycodes): Postalcode

```

#### Parameters

[](#parameters-5)

**countrycode**

Country code in [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) format.

### Postal Code (static instantiation with reference)

[](#postal-code-static-instantiation-with-reference)

```
public static Intervention\Validation\Rules\Postalcode::reference(string $reference): Postalcode

```

#### Parameters

[](#parameters-6)

**reference**

Reference key to get [ISO-639-1](https://en.wikipedia.org/wiki/ISO_639-1) country code from other data in validator.

### Semantic Version Number

[](#semantic-version-number)

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

```
public Intervention\Validation\Rules\SemVer::__construct()

```

### SEO-friendly short text (Slug)

[](#seo-friendly-short-text-slug)

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

```
public Intervention\Validation\Rules\Slug::__construct()

```

### Snake case string

[](#snake-case-string)

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

```
public Intervention\Validation\Rules\Snakecase::__construct()

```

### Title case string

[](#title-case-string)

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

```
public Intervention\Validation\Rules\Titlecase::__construct()

```

### Universally Unique Lexicographically Sortable Identifier (ULID)

[](#universally-unique-lexicographically-sortable-identifier-ulid)

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

```
public Intervention\Validation\Rules\Ulid::__construct()

```

### Upper case string

[](#upper-case-string)

The field under validation must be all upper case.

```
public Intervention\Validation\Rules\Uppercase::__construct()

```

### Username

[](#username)

The field under validation must be a valid username. 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.

```
public Intervention\Validation\Rules\Username::__construct()

```

Development &amp; Testing
-------------------------

[](#development--testing)

With this package comes a Docker image to build a test suite container. To build this container you have to have Docker installed on your system. You can run all tests with this command.

```
$ docker-compose run --rm --build tests

```

Authors
-------

[](#authors)

This library is developed and maintained by [Oliver Vogel](https://intervention.io)

Thanks to the community of [contributors](https://github.com/Intervention/validation/graphs/contributors) who have helped to improve this project.

License
-------

[](#license)

Intervention Validation is licensed under the [MIT License](LICENSE).

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance85

Actively maintained with recent releases

Popularity67

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 88.5% 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

Every ~46 days

Recently: every ~104 days

Total

104

Last Release

79d ago

Major Versions

1.4.2 → 2.0.12020-02-15

1.4.3 → 2.5.12020-09-23

v2.x-dev → 3.0.0-alpha.12021-09-29

3.3.2 → 4.0.0-alpha.12023-06-15

3.3.3 → 4.0.02023-12-10

PHP version history (9 changes)1.0.0PHP &gt;=5.3.0

1.4.0PHP ^7.2

2.0.0-beta1PHP ^7.1

2.6.2PHP ^7.3

2.6.5PHP ^7.3|^8.0

3.0.0-alpha.1PHP ^7.4|^8.0

3.0.0-beta.1PHP ^7.3|^7.4|^8.0

4.0.0-alpha.1PHP ^8.0

4.0.0-beta.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d172b42b2c5b53e71e56589fed3fb3467234a1c266d31b697b1d7b451f4cfe8?d=identicon)[olivervogel](/maintainers/olivervogel)

---

Top Contributors

[![olivervogel](https://avatars.githubusercontent.com/u/884642?v=4)](https://github.com/olivervogel "olivervogel (376 commits)")[![topjor](https://avatars.githubusercontent.com/u/6335056?v=4)](https://github.com/topjor "topjor (7 commits)")[![Okipa](https://avatars.githubusercontent.com/u/5328934?v=4)](https://github.com/Okipa "Okipa (5 commits)")[![daniel-de-wit](https://avatars.githubusercontent.com/u/3015394?v=4)](https://github.com/daniel-de-wit "daniel-de-wit (4 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (3 commits)")[![lkrempler](https://avatars.githubusercontent.com/u/5972830?v=4)](https://github.com/lkrempler "lkrempler (3 commits)")[![Metrakit](https://avatars.githubusercontent.com/u/3305600?v=4)](https://github.com/Metrakit "Metrakit (3 commits)")[![aemaddin](https://avatars.githubusercontent.com/u/11630742?v=4)](https://github.com/aemaddin "aemaddin (2 commits)")[![FlorianW208](https://avatars.githubusercontent.com/u/68705032?v=4)](https://github.com/FlorianW208 "FlorianW208 (1 commits)")[![Ivanshamir](https://avatars.githubusercontent.com/u/29983451?v=4)](https://github.com/Ivanshamir "Ivanshamir (1 commits)")[![jansgescheit](https://avatars.githubusercontent.com/u/21027386?v=4)](https://github.com/jansgescheit "jansgescheit (1 commits)")[![joostdebruijn](https://avatars.githubusercontent.com/u/1844089?v=4)](https://github.com/joostdebruijn "joostdebruijn (1 commits)")[![debiprasad](https://avatars.githubusercontent.com/u/203820?v=4)](https://github.com/debiprasad "debiprasad (1 commits)")[![LorenzoWynberg](https://avatars.githubusercontent.com/u/7880769?v=4)](https://github.com/LorenzoWynberg "LorenzoWynberg (1 commits)")[![clementbirkle](https://avatars.githubusercontent.com/u/9021081?v=4)](https://github.com/clementbirkle "clementbirkle (1 commits)")[![mikkoaf](https://avatars.githubusercontent.com/u/16817737?v=4)](https://github.com/mikkoaf "mikkoaf (1 commits)")[![musaberatbahadir](https://avatars.githubusercontent.com/u/12339284?v=4)](https://github.com/musaberatbahadir "musaberatbahadir (1 commits)")[![MyoStudio](https://avatars.githubusercontent.com/u/2499390?v=4)](https://github.com/MyoStudio "MyoStudio (1 commits)")[![Naoray](https://avatars.githubusercontent.com/u/10154100?v=4)](https://github.com/Naoray "Naoray (1 commits)")[![axlon](https://avatars.githubusercontent.com/u/3661474?v=4)](https://github.com/axlon "axlon (1 commits)")

---

Tags

laravelphpvalidationlaravelvalidatorvalidationbase64ulideancreditcardgtinIBANBICluhnISBNdata-urlISIN

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[ronanguilloux/isocodes

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book and Music Industries, Phone numbers &amp; Zipcodes for many countries

8013.3M23](/packages/ronanguilloux-isocodes)[proengsoft/laravel-jsvalidation

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

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[mvdnbrk/gtin

GTIN / EAN / UPC Validation for Laravel

3148.6k1](/packages/mvdnbrk-gtin)[iamfarhad/validation

🇮🇷 Complete Laravel Persian validation package - Iranian national ID, mobile numbers, Shamsi dates, IBAN/Sheba, postal codes &amp; more. Modern Laravel 10-12 support with both ValidationRule objects &amp; string-based rules.

2917.3k](/packages/iamfarhad-validation)[laravel-validation-rules/timezone

Validate that a given timezone is valid.

2119.0k](/packages/laravel-validation-rules-timezone)

PHPackages © 2026

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