A SOLID validation library that also tries to do KISS.
- Designed with maximum flexibility for customization in mind.
- Tries to be as easy to use and set up as possible.
- Doesn't include message translations intentionally - single responsibility principle - but provides the flexibility to hook your own system in.
- Provides a way to customize the error result.
- It is not exception driven as some other libs.
- No further dependencies.
- Framework-agnostic
This is a very simple example. Please read the documentation.
$fieldBuilder = FieldBuilder::create(new FieldCollection());
$fieldBuilder->add('project.id', NotEmpty::NAME);
$fieldBuilder->add('project.name', Between::NAME, [3,10]);
$fieldBuilder->add('project.tasks.*.title', NotEmpty::NAME);
$fieldCollection = $fieldBuilder->getFieldCollection();
$validator = new Validator(
$fieldCollection,
(new ValidatorFactory())->createRuleCollection(),
new ErrorCollection(),
new GlossaryMessageFormatter()
);
if (!$result->isValid()) {
var_dump($result->getErrors()->toArray());
}
- Copyright (c) 2016-2019 Muhammad Syifa
- Copyright (c) 2021 Dave Redfern
- Copyright (c) 2022 Florian Krämer