klapuch / validation
Broad variation of validation
Installs: 7 090
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=7.1
- ext-mbstring: *
Requires (Dev)
- consistence/coding-standard: ^3.0
- jakub-onderka/php-parallel-lint: ^1.0.0
- mockery/mockery: ^1.0.0
- nette/tester: ^2.0
- phing/phing: ^2.16
- phpstan/phpstan: ^0.10.1
- phpstan/phpstan-strict-rules: *
- sebastian/phpcpd: ^4.0.0
- slevomat/coding-standard: ^4.8.3
README
Documentation
Installation
composer require klapuch/validation
Usage
Single rule
(new EmptyRule())->satified('abc'); // false (new EmptyRule())->satified(''); // true (new EmptyRule())->apply('abc'); // \UnexpectedValueException - 'Subject is not empty' (new FriendlyRule(new EmptyRule(), 'Not empty!'))->apply('abc'); // \UnexpectedValueException - 'Not empty!'
Chained rule
(new ChainedRule( new FriendlyRule( new NegateRule(new EmptyRule()), 'Value can not be empty' ), new LengthRule(10), new PassiveRule, // it does nothing new EmailRule(), ))->apply('abc');
The above code says that a value can not be empty, length of the value must be exact 10 characters and the value must be email.