PHPackages                             krazydanny/laravel-validator - 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. krazydanny/laravel-validator

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

krazydanny/laravel-validator
============================

An Extended Laravel Validator with many useful additional rules!

v1.0.4(5y ago)230MITPHP

Since Apr 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/krazydanny/laravel-validator)[ Packagist](https://packagist.org/packages/krazydanny/laravel-validator)[ RSS](/packages/krazydanny-laravel-validator/feed)WikiDiscussions master Synced today

READMEChangelog (8)DependenciesVersions (11)Used By (0)

Laravel Extended Validator
==========================

[](#laravel-extended-validator)

[![Latest Stable Version](https://camo.githubusercontent.com/ef9f1982bfcb9a0437ed3e36fedb9691ddc96ea5849d8c8dd7851c12fb4a3685/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6b72617a7964616e6e792f6c61726176656c2d76616c696461746f723f696e636c7564655f70726572656c6561736573)](https://packagist.org/packages/krazydanny/laravel-validator) [![Donate](https://camo.githubusercontent.com/d47cdb766a100070d38a702d9c7760ccc8052063484e1478a26bcd16680d33af/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d70617970616c2d626c75652e737667)](https://paypal.me/danielspadafora) [![License](https://camo.githubusercontent.com/8fe0089150cafb3b029dde2c7dcbb4aad539b6c9cc0aefe4dfd26778c3e7c001/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b72617a7964616e6e792f6c61726176656c2d76616c696461746f72)](https://github.com/krazydanny/laravel-validator/blob/master/LICENSE)

This package provides an Extended Laravel Validator with many useful additional rules!

- [Laravel Excended Validator](#laravel-extended-validator)
    - [Main Advantages](#main-advantages)
        - [Time-Saving](#time-saving)
        - [Exclusive validation rules](#exclusive-validation-rules)
    - [Installation](#installation)
        - [Laravel version Compatibility](#laravel-version-compatibility)
        - [Lumen version Compatibility](#lumen-version-compatibility)
        - [Install the package via Composer](#install-the-package-via-composer)
    - [Usage](#usage)
    - [Rules](#rules)

Main Advantages
---------------

[](#main-advantages)

### Time-Saving

[](#time-saving)

Extends Laravel's great built-in validator with commonly used validation rules avoiding you to search the internet for "the golden regex" and extending validator yourself :)

Just register the service provider and rules are ready to use!

### Excusive validation rules

[](#excusive-validation-rules)

Some hard-to-find validation rules available for you as if they where included in Laravel.

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

[](#installation)

The only requirement is to have a Laravel or Lumen project. I asume your are already familiar with one of them, otherwise here are some docs about this great framework:

- Laravel -&gt;
- Lumen -&gt;

### Laravel version Compatibility

[](#laravel-version-compatibility)

LaravelPackage5.6.x1.0.45.7.x1.0.45.8.x1.0.46.x1.0.47.x1.0.4### Lumen version Compatibility

[](#lumen-version-compatibility)

LumenPackage5.6.x1.0.45.7.x1.0.45.8.x1.0.46.x1.0.47.x1.0.4### Install the package via Composer

[](#install-the-package-via-composer)

```
$ composer require krazydanny/laravel-validator
```

Usage
-----

[](#usage)

We only have to register the service provider in our project and all new rules are ready to use :)

```
$app->register( KrazyDanny\Laravel\Validation\ServiceProvider::class );
```

For example:

```
$myValidator = Validator::make(
	$values,
	[
		'lat' => 'latitude',
		'lng' => 'longitude',
		'mac' => 'mac_address',
	],
	$messages
);
```

Rules
-----

[](#rules)

Here's a list of all available validation rules:

- [array\_of\_regex](#array_of_regex)
- [alpha\_blank](#alpha_blank)
- [boolean\_strict](#boolean_strict)
- [camel\_case](#camel_case)
- [color\_hex](#color_hex)
- [date\_gt\_max](#date_gt_max)
- [date\_gt\_min](#date_gt_min)
- [date\_lt\_max](#date_lt_max)
- [date\_lt\_min](#date_lt_min)
- [document\_number](#document_number)
- [float](#float)
- [geo\_distance](#geo_distance)
- [kebab\_case](#kebab_case)
- [latitude](#latitude)
- [longitude](#longitude)
- [mac\_address](#mac_address)
- [object](#object)
- [pascal\_case](#pascal_case)
- [snake\_case](#snake_case)

### array\_of\_regex

[](#array_of_regex)

Iterates array values verifying each element matches a given regular expression.

Synthax:

*array\_of\_regex*

```
$myValidator = Validator::make(
	$values,
	[
		'attributes' => 'array_of_regex:/(some_regex)/',
	],
	[
		'attributes.array_of_regex' => 'Some message',
	]
);
```

MATCH examples:

```
[ 'value A', 'value B', 'value C' ]
[]
```

NO MATCH examples:

```
'value A, value B, value C'
"[ 'value A', 'value B', 'value C' ]"
"[]"
```

### boolean\_strict

[](#boolean_strict)

Checks if value's data type is strictly bool.

Synthax:

*boolean\_strict*

```
$myValidator = Validator::make(
	$values,
	[
		'active' => 'boolean_strict',
	],
	[
		'active.boolean_strict' => 'Some message',
	]
);
```

MATCH examples:

```
true
false
```

NO MATCH examples:

```
1
0
'true'
'false'
```

### camel\_case

[](#camel_case)

Checks if value is a string formatted using camelCase notation.

Synthax:

*camel\_case*

```
$myValidator = Validator::make(
	$values,
	[
		'var_name' => 'camel_case',
	],
	[
		'var_name.camel_case' => 'Some message',
	]
);
```

MATCH examples:

```
'camel',
'camelCase'
'camelCaseN'
'camelCaseNotation'
```

NO MATCH examples:

```
'Camel',
'CamelCase',
'camelcase',
'NCamelCase'
```

### color\_hex

[](#color_hex)

Checks if a string represents a hexadecimal color code.

Synthax:

*color\_hex*

```
$myValidator = Validator::make(
	$values,
	[
		'color'  => 'color_hex',
		'colors' => 'color_hex', // also works with an array of values
	],
	[
		'color.color_hex' => 'Some message',
	]
);
```

MATCH examples:

```
'#FFFFFF'
'#FF3333'
'#ffffff'
'#5AD66A'
```

NO MATCH examples:

```
'FFFFFF'
'#FF33'
'#FF3333A'
'#'
```

### date\_gt\_min

[](#date_gt_min)

Checks if a date (value) is greater than another date (first parameter) at least by the given seconds (second parameter).

Third parameter (optional) could be date's (value) format.

Synthax:

*date\_gt\_min:lower\_date,diff\_in\_seconds,format*

```
$myValidator = Validator::make(
	$values,
	[
		'start_at' => 'date_gt_min:2020-03-01 00:00:00,86400',
	],
	[
		'start_at.date_gt_min' => 'Some message',
	]
);
```

### date\_gt\_max

[](#date_gt_max)

Checks if a date (value) is greater than another date (first parameter) by the given seconds as much (second parameter).

Third parameter (optional) could be date's (value) format.

Synthax:

*date\_gt\_max:lower\_date,diff\_in\_seconds,format*

```
$myValidator = Validator::make(
	$values,
	[
		'start_at' => 'date_gt_max:2020-03-01 00:00:00,86400',
	],
	[
		'start_at.date_gt_max' => 'Some message',
	]
);
```

### date\_lt\_min

[](#date_lt_min)

Checks if a date (value) is lower than another date (first parameter) at least by the given seconds (second parameter).

Third parameter (optional) could be date's (value) format.

Synthax:

*date\_lt\_min:greater\_date,diff\_in\_seconds,format*

```
$myValidator = Validator::make(
	$values,
	[
		'start_at' => 'date_lt_min:2020-03-01 00:00:00,86400',
	],
	[
		'start_at.date_lt_min' => 'Some message',
	]
);
```

### date\_lt\_max

[](#date_lt_max)

Checks if a date (value) is lower than another date (first parameter) by the given seconds as much (second parameter).

Third parameter (optional) could be date's (value) format.

Synthax:

*date\_lt\_max:greater\_date,diff\_in\_seconds,format*

```
$myValidator = Validator::make(
	$values,
	[
		'start_at' => 'date_lt_max:2020-03-01 00:00:00,86400',
	],
	[
		'start_at.date_lt_max' => 'Some message',
	]
);
```

### document\_number

[](#document_number)

Checks if value is a valid reference number for any kind of document or paper.

Synthax:

```
$myValidator = Validator::make(
	$values,
	[
		'id_doc'       => 'document_number',
		'license_num'  => 'document_number',
		'passport_num' => 'document_number',
	],
	[
		'passport_num.document_number' => 'Some message',
	]
);
```

MATCH examples:

```
'123123123123'
'abcabcabcabc'
'a1b2c3d4e5f6'
'20-30764053-0'
'20/30764053/0'
'20 30764053 0'
'20/3076 405-30'
'20/3076.405-30'
'a1-b2c3d4e5f-6'
```

NO MATCH examples:

```
'20--30764053-0'
'20//30764053/0'
'20  30764053 0'
'20/3076..405-30'
'N° 23123123312'
'n° 23123123312'
'n°23123123312'
```

### float

[](#float)

Checks if value is a floating point number. With the 'strict' parameter also checks the data type.

Synthax:

```
$myValidator = Validator::make(
	$values,
	[
		'price' => 'float',
		'rate'  => 'float:strict',
	],
	[
		'price.float' => 'Some message',
		'rate.float'  => 'Some message',
	]
);
```

MATCH examples:

```
0
100
0.00
0.01
100.00
100.01
'0'
'100'
'0.00'
'0.01'
'100.00'
'100.01'
```

NO MATCH examples:

```
'0,00'
'100,00'
```

### geo\_distance

[](#geo_distance)

Checks if value is an integer representing "earth distance". Value can specify the following units at the end of the value: "km" or "m"

Synthax:

```
$myValidator = Validator::make(
	$values,
	[
		'distance' => 'geo_distance',
		'radius'   => 'geo_distance',
	],
	[
		'distance.geo_distance' => 'Some message',
		'radius.geo_distance'   => 'Some message',
	]
);
```

MATCH examples:

```
0
100
1000
'0'
'1m'
'100km'
```

NO MATCH examples:

```
-1
'-1m'
'100k'
```

### kebab\_case

[](#kebab_case)

Checks if value is a string formatted using kebab-case notation.

Synthax:

*kebab\_case*

```
$myValidator = Validator::make(
	$values,
	[
		'category' => 'kebab_case',
	],
	[
		'category.kebab_case' => 'Some message',
	]
);
```

MATCH examples:

```
'kebabcase',
'kebab-case'
'kebab-case-notation'
```

NO MATCH examples:

```
'kebabCase',
'kebab-Case',
'Kebab-case',
```

### latitude

[](#latitude)

Checks if value is valid latitude (between 90 and -90 degrees).

Synthax:

*latitude*

```
$myValidator = Validator::make(
	$values,
	[
		'lat' => 'latitude',
	],
	[
		'lat.latitude' => 'Some message',
	]
);
```

MATCH examples:

```
1
90
-90
1.00,
30.010203
-67.50685
90.000000
-80.9999900000999
```

NO MATCH examples:

```
91
-91
-100
180.00
90.00000000000001
-90.00000000000001
```

### longitude

[](#longitude)

Checks if value is valid longitude (between 180 and -180 degrees).

Synthax:

*longitude*

```
$myValidator = Validator::make(
	$values,
	[
		'lng' => 'longitude',
	],
	[
		'lng.longitude' => 'Some message',
	]
);
```

MATCH examples:

```
1
-180
180.00,
30.010203
-67.50685
90.000000
-179.9999900000999
```

NO MATCH examples:

```
181
-181
188.99
200.000
180.00000000000001
-180.00000000000001
```

### mac\_address

[](#mac_address)

Checks if value is a valid IEEE 802 MAC Address.

Synthax:

*mac\_address*

```
$myValidator = Validator::make(
	$values,
	[
		'mac_addr' => 'mac_address',
	],
	[
		'mac_addr.mac_address' => 'Some message',
	]
);
```

MATCH examples:

```
'00:00:00:00:00:00'
'EE:EE:EE:EE:EE:EE'
'A1:01:A2:02:A3:03'
```

NO MATCH examples:

```
000000000000
'A1:01:A2:02'
'A1.01.A2.02.A3.03'
'A1 01 A2 02 A3 03'
'A1:01:A2:02:A3:03:'
```

### object

[](#object)

Checks if value is an object or an array representing an object.

Synthax:

*object*

```
$myValidator = Validator::make(
	$values,
	[
		'attributes' => 'object',
	],
	[
		'attributes.object' => 'Some message',
	]
);
```

MATCH examples:

```
[ 'fieldA' => 'value A', 'fieldB' => "value B" ]
new stdClass
(object)[ 'field' => 'value' ]
```

NO MATCH examples:

```
[ 'value A', 'value B' ]
"{}"
```

### pascal\_case

[](#pascal_case)

Checks if value is a string formatted using PascalCase notation.

Synthax:

*pascal\_case*

```
$myValidator = Validator::make(
	$values,
	[
		'class_name' => 'pascal_case',
	],
	[
		'class_name.pascal_case' => 'Some message',
	]
);
```

MATCH examples:

```
'Pascal'
'Pascalcase'
'PascalCase'
'PascalCaseN'
'PascalCaseNotation'
```

NO MATCH examples:

```
'pascal'
'pascalCase'
'pascalcase'
'nPascalCase'
```

### snake\_case

[](#snake_case)

Checks if value is a string formatted using snake\_case notation.

Synthax:

*snake\_case*

```
$myValidator = Validator::make(
	$values,
	[
		'param_name' => 'snake_case',
	],
	[
		'param_name.snake_case' => 'Some message',
	]
);
```

MATCH examples:

```
'snakecase'
'snake_case'
'snake_case_n'
'n_snake_case'
'snake_case_notation'
```

NO MATCH examples:

```
'Snake_case'
'snake_Case'
'snake_CaseNotation'
'N_snake_case'
'snake_caseN'
'snake_case_N'
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~35 days

Total

8

Last Release

1975d ago

Major Versions

v0.9.2-beta → v1.02020-07-18

### Community

Maintainers

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

---

Top Contributors

[![krazydanny](https://avatars.githubusercontent.com/u/22056203?v=4)](https://github.com/krazydanny "krazydanny (68 commits)")

### Embed Badge

![Health badge](/badges/krazydanny-laravel-validator/health.svg)

```
[![Health](https://phpackages.com/badges/krazydanny-laravel-validator/health.svg)](https://phpackages.com/packages/krazydanny-laravel-validator)
```

###  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)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M448](/packages/nette-forms)[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)

PHPackages © 2026

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