nirgendswo / valitron
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple, elegant, stand-alone validation library with NO dependencies
2.0.1
2016-04-15 15:22 UTC
Requires
- php: >=5.3.2
Requires (Dev)
- phpunit/phpunit: ~4.0
README
This is a Fork of https://github.com/vlucas/valitron
Installation
Valitron uses Composer to install and update:
curl -s http://getcomposer.org/installer | php
php composer.phar require nirgendswo/valitron
Reject
The validation always failed if there is any Data that is not set by the Rules.
Defaults
Default values can be set for each Field, if the Field is not required.
$validator = new Valitron\Validator(['name' => 'Chester Tester']); $validator->setDefault('birthday', '10-01-2015');
You can also set Defaults as array,
$defaults = ['birthday' => '10-01-2015']; $validator = new Valitron\Validator(['name' => 'Chester Tester']); $validator->setDefaults($defaults);
Rule: arrayIn
Performs in_array check on given array values for an array
$data = ['roles' => ['USER']]; $validator = new Valitron\Validator($data); $validator->setRule('arrayIn', 'roles', ['USER', 'ADMIN']);
Running Tests
The test suite depends on the Composer autoloader to load and run the Valitron files. Please ensure you have downloaded and installed Composer before running the tests:
- Download Composer
curl -s http://getcomposer.org/installer | php
- Run 'install'
php composer.phar install
- Run the tests
phpunit
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Make your changes
- Run the tests, adding new ones for your own code if necessary (
phpunit
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- Pat yourself on the back for being so awesome