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
{{ message }}
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
When using the [`assert`](#assert) method to validate a value, an exception is thrown when a rule fails.
190
+
When using the [`assert`](#assert) method, an exception is thrown when a rule fails.
191
191
192
-
Each rule has a unique exception, formed by the name of the rule followed by the work Exception —`RuleNameException`.
192
+
Each rule has a unique exception, formed by the name of the rule followed by the word Exception, like`RuleNameException`.
193
193
The following shows an example:
194
194
195
195
```php
@@ -225,10 +225,12 @@ try {
225
225
}
226
226
catch (ValidationException $exception) {
227
227
// Do something when a rule fails
228
+
echo $exception->getMessage();
228
229
}
229
230
```
230
231
231
-
When using both the [`assert`](#assert) or [`validate`](#validate) methods, an `UnexpectedValueException` is thrown when the provided input data is not valid to perform the validation.
232
+
When using both the [`assert`](#assert) or [`validate`](#validate) methods,
233
+
an `UnexpectedValueException` is thrown when the provided input data is not valid to perform the validation.
232
234
233
235
For example, when trying to compare a date with a string:
234
236
@@ -262,5 +264,5 @@ Validator::choice(
262
264
message: '"{{ value }}" is not a valid {{ name }}! You must select one of {{ constraints }}.'
263
265
)->assert('yellow', 'color');
264
266
265
-
// "yellow" is not a valid color! You must select one of [red, green, blue].
267
+
// Throws: "yellow" is not a valid color! You must select one of [red, green, blue].
0 commit comments