Skip to content

Commit 854ada6

Browse files
authored
Merge pull request #8 from programmatordev/FV-4-symfony-validator-8
Symfony Validator 8.0 support
2 parents c65fe95 + 25d08c2 commit 854ada6

File tree

11 files changed

+170
-103
lines changed

11 files changed

+170
-103
lines changed

.ddev/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: fluent-validator
22
type: php
33
docroot: ""
4-
php_version: "8.2"
4+
php_version: "8.4"
55
webserver_type: nginx-fpm
66
xdebug_enabled: false
77
additional_hostnames: []

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
php: ['8.2', '8.3', '8.4']
19+
php: ['8.4', '8.5']
2020

2121
steps:
2222
- name: Checkout code

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
A [Symfony Validator](https://symfony.com/doc/current/validation.html) wrapper that enables fluent-style validation for raw values,
88
offering 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.
6467
The 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
}
126129
catch (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
178181
use 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())

bin/console

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ require __DIR__ . '/../vendor/autoload.php';
1111

1212
$app = new Application();
1313

14-
$app->add(new CreateStaticValidatorInterfaceCommand());
15-
$app->add(new CreateChainedValidatorInterfaceCommand());
16-
$app->add(new CreateValidatorInterfacesCommand());
14+
$app->addCommand(new CreateStaticValidatorInterfaceCommand());
15+
$app->addCommand(new CreateChainedValidatorInterfaceCommand());
16+
$app->addCommand(new CreateValidatorInterfacesCommand());
1717

1818
$app->run();

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
"license": "MIT",
77
"authors": [
88
{
9-
"name": "André Pimpão",
10-
"email": "a.pimpao@programmator.dev",
9+
"name": "Programmator",
10+
"email": "hotline@programmator.dev",
1111
"homepage": "https://programmator.dev"
1212
}
1313
],
1414
"require": {
15-
"php": ">=8.2",
16-
"symfony/config": "^7.3",
17-
"symfony/translation": "^7.3",
18-
"symfony/validator": "^7.3"
15+
"php": ">=8.4",
16+
"symfony/config": "^8.0",
17+
"symfony/translation": "^8.0",
18+
"symfony/validator": "^8.0"
1919
},
2020
"require-dev": {
2121
"phpunit/phpunit": "^11.5",
22-
"symfony/console": "^7.3",
23-
"symfony/var-dumper": "^7.3",
22+
"symfony/console": "^8.0",
23+
"symfony/var-dumper": "^8.0",
2424
"wyrihaximus/list-classes-in-directory": "^1.7"
2525
},
2626
"autoload": {

0 commit comments

Comments
 (0)