narokishi / object-validator
PHP package to validate objects
dev-master
2018-09-01 15:42 UTC
Requires
- php: >=7.1.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^7.3.2
This package is not auto-updated.
Last update: 2024-05-20 16:50:48 UTC
README
Build | Coverage | Downloads | Release | License |
---|---|---|---|---|
Description
"ObjectValidator" is a PHP package, which allows to validate given class (eg. stdClass incoming from request) to be validated with custom rules. Strongly recommended for generic views.
Installation
Composer
Installing via Composer will keep this package up to date for you.
composer require narokishi/object-validator
Usage
use Narokishi\ObjectValidator\Validators\CompensationValidator; use Narokishi\ObjectValidator\ValidationException; ... try { (new CompensationValidator($class)) ->applyPrefix('compensation') ->withThrow(); } catch (ValidationException $e) { // Apply errors to view or whatever }
Contributing
Thank you for considering contributing to the package.
Running tests
composer tests composer tests-windows
Submitting a Patch
- Fork the Repository
- After the action has completed, clone your fork locally
git clone git@github.com:{username}/object-validator.git
cd number-to-words
git remote add upstream git://github.com/narokishi/object-validator.git
- Check that tests pass
- Create and work on your own topic branch
git checkout -b {branch} master
- Prepare your patch (while rebasing you might have to resolve conflicts)
git checkout master git fetch upstream git merge upstream/master git checkout BRANCH_NAME git rebase master
- In case of conflicts
git add {files} git rebase --continue
- Check that all tests pass and push your branch
git push origin {branch} --force
- Make a Pull Request on narokishi/object-validator repository