https://github.com/phauthentic/validator
A SOLID validation library, flexible and extendible.
https://github.com/phauthentic/validator
dependency-free php8 phpstan-l8 solid solid-principles validation validator
Last synced: about 1 year ago
JSON representation
A SOLID validation library, flexible and extendible.
- Host: GitHub
- URL: https://github.com/phauthentic/validator
- Owner: Phauthentic
- License: mit
- Created: 2023-01-31T01:15:13.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-07T07:39:33.000Z (almost 3 years ago)
- Last Synced: 2025-05-30T09:58:04.329Z (about 1 year ago)
- Topics: dependency-free, php8, phpstan-l8, solid, solid-principles, validation, validator
- Language: PHP
- Homepage:
- Size: 113 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Phauthentic Validator



A [SOLID][1] validation library that also tries to do [KISS][2].
* 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
## Example
This is a **very** simple **example**. Please read the documentation.
```php
$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());
}
```
## Documentation
* [Quick Start](docs/Quick-Start.md)
* [Architecture of the Library](docs/Architecture.md)
## License
[The MIT License (MIT)](LICENSE)
- Copyright (c) 2016-2019 Muhammad Syifa
- Copyright (c) 2021 Dave Redfern
- Copyright (c) 2022 Florian Krämer
[1]: https://en.wikipedia.org/wiki/SOLID
[2]: https://en.wikipedia.org/wiki/KISS_principle