An extension to Laravel's Validator class that provides some additional validation rules.
mallardduck/extended-validator-laravel is a Laravel package for an extension to laravel's validator class that provides some additional validation rules..
It currently has 0 GitHub stars and 1.231 downloads on Packagist (latest version 5.0.0).
Install it with composer require mallardduck/extended-validator-laravel.
Discover more Laravel packages by mallardduck
or browse all Laravel packages to compare alternatives.
Last updated
An extension to Laravel's Validator class that provides some additional validation rules.
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.
| PHP | Package | |-----|---------| | 8.0 | Current | | 7.4 | 2.3.1 |
PublicIpPublicIpv4NonPublicIpv4NotInIfNotInIfValuePublicIpv6ProhibitedIfProhibitedWithProhibitedWithAllPublicIpDetermine 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',
];
PublicIpv4Determine 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',
];
NonPublicIpv4Determine 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',
];
NotInIfnot_in_if:anotherfield,value,...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 rule.
$rules = [
'size' => ['sometimes', 'not_in_if_value:is_square,large,super', 'in:small,medium,large,super',],
'is_square' => ['required', 'boolean'],
];
NotInIfValuenot_in_if_value:anotherfield,anotherfield_value,value,...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 rule.
$rules = [
'size' => ['sometimes', 'not_in_if_value:shape,square,large,super', 'in:small,medium,large,super',],
'shape' => ['required', 'in:square,rectangle'],
];
PublicIpv6Determine 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',
];
ProhibitedIfIt'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: https://laravel.com/docs/8.x/validation#rule-prohibited-if
Probhits aka ProhibitedWithIt'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: https://laravel.com/docs/9.x/validation#rule-prohibits
ProhibitedWithAllUse 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'
];
composer test
composer check-style
Note: The tests are great examples of potential uses for these rules.
The MIT License (MIT). Please see License File for more information.