Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77f39fe

Browse files
committed
bug #53350 [Validator] fix the exception being thrown (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] fix the exception being thrown | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT An `UnexpectedValueException` is caught and transformed into a violation (`UnexpectedTypeException` indicates a misconfiguration of a constraint and is not caught). see also #27917 Commits ------- 3a8f10b fix the exception being thrown
2 parents df36583 + 3a8f10b commit 77f39fe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Component/Validator/Constraints/JsonValidator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\ConstraintValidator;
1616
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
17+
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1718

1819
/**
1920
* @author Imad ZAIRIG <[email protected]>
@@ -34,7 +35,7 @@ public function validate($value, Constraint $constraint)
3435
}
3536

3637
if (!\is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
37-
throw new UnexpectedTypeException($value, 'string');
38+
throw new UnexpectedValueException($value, 'string');
3839
}
3940

4041
$value = (string) $value;

0 commit comments

Comments
 (0)