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

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

marshmallow/validation
======================

Additional validation rules for the Laravel framework

v4.4.0(2mo ago)04.4k↓50%1MITPHPPHP ^8.1

Since Jan 7Pushed 2mo ago2 watchersCompare

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

READMEChangelog (4)Dependencies (12)Versions (5)Used By (0)

Validation
==========

[](#validation)

`marshmallow-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/a1ed3950eda838279473d306035e5c1254f494441472b9c2fe8ee4b0fecef9ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f76616c69646174696f6e2e737667)](https://packagist.org/packages/marshmallow/validation)[![Monthly Downloads](https://camo.githubusercontent.com/758a5e03a967d492dd1961451ebf3c9113de6c0cb5658325400297aa02cf6cf3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d617273686d616c6c6f772f76616c69646174696f6e2e737667)](https://packagist.org/packages/marshmallow/validation/stats)

Important

This package was originally forked from [intervention/validation](https://github.com/Intervention/validation). Since we were making many opinionated changes and the owner archived the repository, we decided to continue development in our own version rather than submitting pull requests that might not benefit all users of the original package. You're welcome to use this package, we're actively maintaining it. If you encounter any issues, please don't hesitate to reach out.

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

[](#installation)

You can install this package quick and easy with Composer.

Require the package via Composer:

```
$ composer require marshmallow/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 30 additional validation rules including multi language error messages, which can be used like Laravel's own validation rules.

```
use Illuminate\Support\Facades\Validator;
use Marshmallow\Validation\Rules\Creditcard;
use Marshmallow\Validation\Rules\Hexadecimalcolor;
use Marshmallow\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.

### Base64 encoded string

[](#base64-encoded-string)

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

```
public Marshmallow\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 Marshmallow\Validation\Rules\Bic::__construct()

```

### Camel case string

[](#camel-case-string)

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

```
public Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 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 Marshmallow\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 Marshmallow\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.

### Text without HTML

[](#text-without-html)

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

```
public Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\Validation\Rules\Isin::__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 Marshmallow\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 Marshmallow\Validation\Rules\Jwt::__construct()

```

### Kebab case string

[](#kebab-case-string)

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

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

```

### Lower case string

[](#lower-case-string)

The given value must be all lower case letters.

```
public Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\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 Marshmallow\Validation\Rules\Slug::__construct()

```

### Snake case string

[](#snake-case-string)

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

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

```

### Title case string

[](#title-case-string)

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

```
public Marshmallow\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 Marshmallow\Validation\Rules\Ulid::__construct()

```

### Upper case string

[](#upper-case-string)

The field under validation must be all upper case.

```
public Marshmallow\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 Marshmallow\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

```

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance88

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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

Every ~144 days

Total

4

Last Release

61d ago

### Community

Maintainers

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

---

Top Contributors

[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (8 commits)")

---

Tags

laravelvalidatorvalidationbase64ulideancreditcardgtinIBANBICluhnISBNdata-urlISIN

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[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)

PHPackages © 2026

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