Extra functionality for Laravel 5 Validator.
This class extends Laravel Validation package changing some basic functionality to provide validation of data with wildcards. How do wildcrads work:
Add following line to your
For Laravel 4.x
For Laravel 5.x
composer install or
composer update to download it and autoload.
Once package is installed you need to register it as a service provider. Find
app.php file in your
First, since this package extends default Validation, you need to comment out or remove this line from
Now in the same
providers array you need to add new package:
'providers' => array( //... 'Cohensive\Validation\ValidationServiceProvider', //... )
No need to add anything in
Mostly the same as in core Validation. When it comes to validation with wildcrads here's an example:
$input = array('input' => array('foo', 'bar', 'baz')); $rules = array( 'input:*' => 'Alpha|Min:3' ); $v = Validator::make($input, $rules);
Shall we go deeper?
$input = array('users' => array( 0 => array( 'name' => 'Mike', 'age' => 30 ), 1 => array( 'name' => 'Rob', 'age' => '28' ) )); $rules = array( 'users:*:name' => 'Alpha|Min:3', 'users:*:age' => 'Numeric|Min:18|Max:80' ); $v = Validator::make($input, $rules);