lbacik/value-object-illuminate-validation

Validator wrapper (to be used with ValueObject) for Illuminate Validation class

v0.4 2022-02-15 19:20 UTC

This package is not auto-updated.

Last update: 2024-04-24 06:40:46 UTC


README

Build Status

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!