You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-1Lines changed: 59 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ offering an easy-to-use and intuitive API to validate user input or other data i
21
21
## Table of Contents
22
22
23
23
-[Installation](#installation)
24
+
-[When to use it](#when-to-use-it)
24
25
-[Usage](#usage)
25
26
-[Constraints](#constraints)
26
27
-[Methods](#methods)
@@ -30,6 +31,7 @@ offering an easy-to-use and intuitive API to validate user input or other data i
30
31
-[toArray](#toarray)
31
32
-[addNamespace](#addnamespace)
32
33
-[setTranslator](#settranslator)
34
+
-[reset](#reset)
33
35
-[Custom Constraints](#custom-constraints)
34
36
-[Translations](#translations)
35
37
@@ -45,6 +47,13 @@ Install via [Composer](https://getcomposer.org/):
45
47
composer require programmatordev/fluent-validator
46
48
```
47
49
50
+
## When to use it
51
+
52
+
Use Fluent Validator when you want Symfony Validator constraints for raw values without setting up object metadata, attributes, forms, or a larger validation layer.
53
+
It is useful for small input checks, command arguments, request fragments, webhook payload values, configuration values, and library code.
54
+
55
+
This package does not replace Symfony Validator. It wraps Symfony Validator and keeps its constraints, violation objects, groups, translations, and custom constraint model.
56
+
48
57
## Usage
49
58
50
59
Simple usage example:
@@ -63,7 +72,33 @@ if ($errors->count() > 0) {
63
72
}
64
73
```
65
74
75
+
Use `assert` when invalid values should stop the current flow:
76
+
77
+
```php
78
+
use ProgrammatorDev\FluentValidator\Exception\ValidationFailedException;
All available constraints can be found on the [Symfony Validator documentation](https://symfony.com/doc/current/validation.html#constraints).
@@ -209,6 +258,15 @@ Used to add a translator for validation error message translations.
209
258
210
259
Check the [Translations](#translations) section.
211
260
261
+
### `reset`
262
+
263
+
```php
264
+
reset(): void
265
+
```
266
+
267
+
Clears globally registered custom constraint namespaces and translator configuration.
268
+
Useful when changing global validator configuration in tests, workers, or other long-running PHP processes.
269
+
212
270
## Custom Constraints
213
271
214
272
If you need a custom constraint, follow the Symfony Validator documentation: [Creating Custom Constraints](https://symfony.com/doc/current/validation/custom_constraint.html).
@@ -291,4 +349,4 @@ Make sure to open a pull request or issue.
291
349
## License
292
350
293
351
This project is licensed under the MIT license.
294
-
Please see the [LICENSE](LICENSE) file distributed with this source code for further information regarding copyright and licensing.
352
+
Please see the [LICENSE](LICENSE) file distributed with this source code for further information regarding copyright and licensing.
0 commit comments