77A [ Symfony Validator] ( https://symfony.com/doc/current/validation.html ) wrapper that enables fluent-style validation for raw values,
88offering an easy-to-use and intuitive API to validate user input or other data in a concise and readable manner.
99
10+ > [ !NOTE]
11+ > This library will always (try to) be in sync with the latest Symfony Validator version.
12+
1013## Features
1114
1215- 🌊 ** Fluent-style validation:** Chain validation methods for better readability and flow.
1316- 🤘 ** Constraints autocompletion:** Enables IDE autocompletion for available constraints.
1417- 🔥 ** Three validation methods:** Use ` validate ` , ` assert ` , or ` isValid ` based on the context (i.e., collect errors or throw exceptions).
15- - ⚙️ ** Custom constraints:** Easily integrate custom validation logic with Symfony's Validator system.
18+ - ⚙️ ** Custom constraints:** Integrate custom validation logic with Symfony's Validator system.
1619- 💬 ** Translations support:** Translate validation error messages into multiple languages.
1720
1821## Table of Contents
@@ -32,7 +35,7 @@ offering an easy-to-use and intuitive API to validate user input or other data i
3235
3336## Requirements
3437
35- - PHP 8.2 or higher.
38+ - PHP 8.4 or higher.
3639
3740## Installation
3841
@@ -60,7 +63,7 @@ if ($errors->count() > 0) {
6063}
6164```
6265
63- Constraints autocompletion is available in IDEs like PhpStorm.
66+ Constraint autocompletion is available in IDEs like PhpStorm.
6467The method names match Symfony constraints but with a lowercase first letter:
6568
6669- ` NotBlank ` => ` notBlank `
@@ -124,10 +127,10 @@ try {
124127 Validator::notBlank()->email()->assert($email);
125128}
126129catch (ValidationFailedException $exception) {
127- // exception message will always be the first error thrown
130+ // the exception message will always be the first error thrown
128131 $message = $exception->getMessage();
129132 // value that failed validation
130- $value = $exception->getInvalidValue();
133+ $invalidValue = $exception->getInvalidValue();
131134 // get access to all errors
132135 // returns a ConstraintViolationList object like in the validate method
133136 $errors = $exception->getViolations();
@@ -177,7 +180,7 @@ and keeps the fluent-style validation:
177180``` php
178181use ProgrammatorDev\FluentValidator\Validator;
179182
180- // validate that array should have at least one value
183+ // validate that the array should have at least one value
181184// and each value should be between 0 and 100
182185$errors = Validator::count(min: 1)
183186 ->all(Validator::range(min: 0, max: 100)->toArray())
0 commit comments