Skip to content

Commit e36248e

Browse files
committed
docs: update requirements and grammar improvements
1 parent 4ed19a7 commit e36248e

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

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())

src/Validator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __call(string $constraintName, array $arguments = []): self
4545
return $this;
4646
}
4747

48-
public function validate(mixed $value, ?string $name = null, string|GroupSequence|array|null $groups = null): ConstraintViolationListInterface
48+
public function validate(mixed $value, ?string $name = null, array|null|string|GroupSequence $groups = null): ConstraintViolationListInterface
4949
{
5050
$builder = Validation::createValidatorBuilder();
5151

@@ -64,7 +64,7 @@ public function validate(mixed $value, ?string $name = null, string|GroupSequenc
6464
return $context->getViolations();
6565
}
6666

67-
public function assert(mixed $value, ?string $name = null, string|GroupSequence|array|null $groups = null): void
67+
public function assert(mixed $value, ?string $name = null, array|null|string|GroupSequence $groups = null): void
6868
{
6969
$violations = $this->validate($value, $name, $groups);
7070

@@ -80,7 +80,7 @@ public function assert(mixed $value, ?string $name = null, string|GroupSequence|
8080
}
8181
}
8282

83-
public function isValid(mixed $value, string|GroupSequence|array|null $groups = null): bool
83+
public function isValid(mixed $value, array|null|string|GroupSequence $groups = null): bool
8484
{
8585
$violations = $this->validate($value, groups: $groups);
8686

0 commit comments

Comments
 (0)