omasn / reflection-validator
Extends the capability of the symfony validator
Installs: 1 283
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=8.2
- symfony/property-info: ^6.3
- symfony/validator: ^6.3
Requires (Dev)
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^4.0|^5.4
- vimeo/psalm: ^4.30
README
Extends the capability of the symfony validator
Installation
Install the latest version with
$ composer require omasn/reflection-validator
Basic Usage
Example 1:
class A { public int $number; /** @var B[] */ public array $rows; } class B { public int $number; /** @var C[] */ public array $rows; } class C { #[Assert\Positive] public int $number; } $reflValidator = Omasn\ReflectionValidator\ReflectionValidator::createSimple(); $violations = $reflValidator->validate(A::class, [ 'number' => 0, 'rows' => [ [ 'number' => 0, 'rows' => [ [ 'number' => -1, ], ], ], ], ]); self::assertEquals(1, $violations->count());
For contributors
Install cs-fixer
mkdir -p tools/php-cs-fixer
composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer
Run tests
Exec: ./vendor/bin/phpunit
Run lint
Exec cs-fixer: tools/php-cs-fixer/vendor/bin/php-cs-fixer fix src
Exec phpstan: ./vendor/bin/phpstan analyse src tests
Exec psalm: ./vendor/bin/psalm