Skip to content

phppoint/validator

Repository files navigation

PHPyh Validator

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

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published