https://github.com/programmatordev/yet-another-php-validator
PHP validator with expressive error messages
https://github.com/programmatordev/yet-another-php-validator
php php-validation php-validator php8 validation validator
Last synced: 9 months ago
JSON representation
PHP validator with expressive error messages
- Host: GitHub
- URL: https://github.com/programmatordev/yet-another-php-validator
- Owner: programmatordev
- License: mit
- Archived: true
- Created: 2023-07-21T12:31:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-13T17:39:12.000Z (10 months ago)
- Last Synced: 2025-03-22T15:22:57.011Z (10 months ago)
- Topics: php, php-validation, php-validator, php8, validation, validator
- Language: PHP
- Homepage:
- Size: 390 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yet Another PHP Validator
[](https://github.com/programmatordev/yet-another-php-validator/releases)
[](LICENSE)
[](https://github.com/programmatordev/yet-another-php-validator/actions/workflows/ci.yml?query=branch%3Amain)
PHP validator with expressive error messages.
> [!TIP]
> This library has been archived in favor of the [Fluent Validator](https://github.com/programmatordev/fluent-validator) library.
> Check it out if you're interested in the same validation style.
## Requirements
- PHP 8.1 or higher.
## Installation
Install the library via [Composer](https://getcomposer.org/):
```bash
composer require programmatordev/yet-another-php-validator
```
## Basic Usage
Simple usage looks like:
```php
use ProgrammatorDev\Validator\Validator;
// do this:
$validator = Validator::type('int')->greaterThanOrEqual(18);
// and validate with these:
$validator->validate(16); // returns bool: false
$validator->assert(16, 'age'); // throws exception: The age value should be greater than or equal to 18.
```
## Documentation
- [Get Started](docs/01-get-started.md)
- [How to Use](docs/02-usage.md)
- [Usage](docs/02-usage.md#usage)
- [Methods](docs/02-usage.md#methods)
- [Error Handling](docs/02-usage.md#error-handling)
- [Custom Error Messages](docs/02-usage.md#custom-error-messages)
- [Rules](docs/03-rules.md)
- [Custom Rules](docs/04-custom-rules.md)
## Contributing
Any form of contribution to improve this library (including requests) will be welcome and appreciated.
Make sure to open a pull request or issue.
## Acknowledgments
This library is inspired by [respect/validation](https://github.com/Respect/Validation) and [symfony/validator](https://github.com/symfony/validator).
## License
This project is licensed under the MIT license.
Please see the [LICENSE](LICENSE) file distributed with this source code for further information regarding copyright and licensing.