phpyh/validator

Mother's friend's son's validator

dev-master / 0.1.x-dev 2020-10-02 01:40 UTC

This package is auto-updated.

Last update: 2024-11-29 06:28:47 UTC


README

«Валидатор сына маминой подруги», — Роман Пронский.

alt text

namespace PHPyh\Validator;

$validator = new Validator(
    new RuleHandlerRegistry\InMemoryRuleHandlerRegistry([
        new Rule\AllHandler(),
        new Rule\AnyHandler(),
        new Rule\ObjectPropertiesHandler(),
        new Rule\GreaterThanHandler(),
    ])
);

final class SomeDto
{
    public int $age = 10;
    public int $height = 130;
}

$errors = $validator->validate(
    new SomeDto(),
    new Rule\Any([
        new Rule\ObjectProperties([
            'age' => new Rule\GreaterThan(18),
            'height' => new Rule\GreaterThan(150),
        ])
    ])
);

References