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

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

mallardduck/extended-validator-laravel
======================================

An extension to Laravel's Validator class that provides some additional validation rules.

5.0.0(1y ago)01.2kMITPHPPHP ^8.0

Since Sep 24Pushed 1y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (14)Versions (26)Used By (0)

Extended Validation for Laravel
===============================

[](#extended-validation-for-laravel)

[![Maintainability](https://camo.githubusercontent.com/f9f069b9a45479121b7662472018fd2478fb17cde96330670c3360dc6d89dfd8/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31623765323639626261383966653537653730332f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/mallardduck/extended-validator-laravel/maintainability)[![Test Coverage](https://camo.githubusercontent.com/7ee7eb6eea4bed3caa5b271e9a7eb344d04a03984af2ecce14a79c212f424fa0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31623765323639626261383966653537653730332f746573745f636f766572616765)](https://codeclimate.com/github/mallardduck/extended-validator-laravel/test_coverage)[![codecov](https://camo.githubusercontent.com/7f50b7de7e451d3e06047850c9ff01ab5483c4d33a1539f4bba4a0fc0fd0eb33/68747470733a2f2f636f6465636f762e696f2f67682f6d616c6c6172646475636b2f657874656e6465642d76616c696461746f722d6c61726176656c2f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/mallardduck/extended-validator-laravel)[![Coverage Status](https://camo.githubusercontent.com/4b09e8ea43961c9eea1d17ebe3a46915850f71e099732ebc993426dcb465c920/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d616c6c6172646475636b2f657874656e6465642d76616c696461746f722d6c61726176656c2f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/mallardduck/extended-validator-laravel?branch=main)

An extension to Laravel's Validator class that provides some additional validation rules.

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

[](#installation)

You can install the package via composer:

```
composer require mallardduck/extended-validator-laravel

```

Just require the project and Laravel's Service Provider Auto-discovery will do the rest.
All the new rules will be automatically registered for use without any configuration.

Requirements
------------

[](#requirements)

- PHP 8.x
- Laravel 8.32.x (or greater)

### Past PHP version support

[](#past-php-version-support)

PHPPackage8.0Current7.42.3.1Available Rules
---------------

[](#available-rules)

- [`PublicIp`](#publicip)
- [`PublicIpv4`](#publicipv4)
- [`NonPublicIpv4`](#nonpublicipv4)
- [`NotInIf`](#notinif)
- [`NotInIfValue`](#notinifvalue)
- [`PublicIpv6`](#publicipv6)
- [`ProhibitedIf`](#prohibitedif)
- [`ProhibitedWith`](#prohibitedwith)
- [`ProhibitedWithAll`](#prohibitedwithall)

### `PublicIp`

[](#publicip)

Determine if the field under validation is a valid public IP address.
Just like Laravel's `ip` rule, but IPs cannot be within private or reserved ranges.

```
$rules = [
    'ip' => 'required|public_ip',
];

```

### `PublicIpv4`

[](#publicipv4)

Determine if the field under validation is a valid public IPv4 address.
Just like Laravel's `ipv4` rule, but IPs cannot be within private or reserved ranges.

```
$rules = [
    'ip' => 'required|public_ipv4',
];

```

### `NonPublicIpv4`

[](#nonpublicipv4)

Determine if the field under validation is a valid non-public IPv4 address.
Just like Laravel's `ipv4` rule, but IPs should only be within private or reserved ranges.

```
$rules = [
    'ip' => 'required|non_public_ipv4',
];

```

### `NotInIf`

[](#notinif)

#### `not_in_if:anotherfield,value,...`

[](#not_in_ifanotherfieldvalue)

The field under validation must not be included in the given list of values only when the given fieled is truthy.
Think of this as a conditional version of [`not_in`](https://laravel.com/docs/8.x/validation#rule-not-in) rule.

```
$rules = [
    'size' => ['sometimes', 'not_in_if_value:is_square,large,super', 'in:small,medium,large,super',],
    'is_square' => ['required', 'boolean'],
];

```

### `NotInIfValue`

[](#notinifvalue)

#### `not_in_if_value:anotherfield,anotherfield_value,value,...`

[](#not_in_if_valueanotherfieldanotherfield_valuevalue)

The field under validation must not be included in the given list of values only when the value of the `anotherfield` field is equal to `anotherfield_value`.
Think of this as a conditional version of [`not_in`](https://laravel.com/docs/8.x/validation#rule-not-in) rule.

```
$rules = [
    'size' => ['sometimes', 'not_in_if_value:shape,square,large,super', 'in:small,medium,large,super',],
    'shape' => ['required', 'in:square,rectangle'],
];

```

### `PublicIpv6`

[](#publicipv6)

Determine if the field under validation is a valid public IPv6 address.
Just like Laravel's `ipv6` rule, but IPs cannot be within private or reserved ranges.

```
$rules = [
    'ip' => 'required|public_ipv4',
];

```

### `ProhibitedIf`

[](#prohibitedif)

It's now suggested that you use the native Laravel version of this rule. This package now requires the version that ships this, so it should be there.

For more info see the docs:

### `Probhits` aka `ProhibitedWith`

[](#probhits-aka-prohibitedwith)

It's now suggested that you use the native Laravel version of this rule, even though it's slightly different. This package will require that version moving forward so the rule will be there.

For more info, see:

### `ProhibitedWithAll`

[](#prohibitedwithall)

Use of the field under validation is prohibited only if all the other specified fields are present.
Think of it as the opposite of Laravel's `required_with_all`.

```
$rules = [
    'name' => 'prohibited_with_all:first_name,middle_name,last_name',
    'first_name' => 'sometimes',
    'middle_name' => 'sometimes',
    'last_name' => 'sometimes'
];

```

Testing
-------

[](#testing)

```
composer test
composer check-style

```

Note: The tests are great examples of potential uses for these rules.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance40

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

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

Recently: every ~256 days

Total

22

Last Release

508d ago

Major Versions

1.2.2 → 2.0.02021-03-08

2.3.1 → 3.0.02021-04-24

3.2.0 → 4.0.02022-10-03

4.0.2 → 5.0.02024-12-21

PHP version history (5 changes)1.0.0PHP ^7.3

2.0.1PHP ^7.3|^8.0

2.1.0PHP ^7.4|^8.0

2.2.0PHP ^7.4 || ^8.0

3.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/801be8ba9bfb0cb2629f51f9753a0392683c2680fe3e941a188495840d920333?d=identicon)[MallardDuck](/maintainers/MallardDuck)

---

Top Contributors

[![mallardduck](https://avatars.githubusercontent.com/u/619938?v=4)](https://github.com/mallardduck "mallardduck (191 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  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)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[proengsoft/laravel-jsvalidation

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

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)

PHPackages © 2026

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