lbacik / value-object-illuminate-validation
Validator wrapper (to be used with ValueObject) for Illuminate Validation class
v0.4
2022-02-15 19:20 UTC
Requires
- php: >=8.0
- illuminate/validation: ^8
- lbacik/value-object: ^0.4
Requires (Dev)
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.6
This package is not auto-updated.
Last update: 2024-10-09 08:39:55 UTC
README
Validator wrapper (to be used with ValueObject) for Illuminate Validation class
ValueObject implementation: https://github.com/lbacik/value-object
Laravel documentation about using Laravel's validator features: https://laravel.com/docs/5.7/validation
Example value object declaration:
class ExampleValueObject extends ValueObject
{
protected $validators = [
KeysValidator::class,
IlluminateValidationValidator::class,
];
protected $keys = [
'id' => 'required|integer|min:1',
'name' => 'required|string|max:5',
'desc' => 'nullable|string|max:100',
];
}
Value object creation and (instant) validation:
$vo = new ExampleValueObject([
'id' => 1,
'name' => 'Ala',
'desc' => 'Sample description',
])
For more examples please check the project's tests!