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

Skip to content

Commit f118c4f

Browse files
committed
support Stringable instances in all constraints
1 parent 82e0eff commit f118c4f

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
lines changed

src/Symfony/Component/Validator/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.1
55
---
66

7+
* Add support for `Stringable` values in `CidrValidator`, `CssColorValidator`, `ExpressionSyntaxValidator` and `PasswordStrengthValidator`
78
* Add `MacAddress` constraint
89
* Add `list` and `associative_array` types to `Type` constraint
910
* Add the `Charset` constraint

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function validate($value, Constraint $constraint): void
2828
return;
2929
}
3030

31-
if (!\is_string($value)) {
31+
if (!\is_string($value) && !$value instanceof \Stringable) {
3232
throw new UnexpectedValueException($value, 'string');
3333
}
3434

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function validate($value, Constraint $constraint): void
6262
return;
6363
}
6464

65-
if (!\is_string($value)) {
65+
if (!\is_string($value) && !$value instanceof \Stringable) {
6666
throw new UnexpectedValueException($value, 'string');
6767
}
6868

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function validate(mixed $expression, Constraint $constraint): void
4040
return;
4141
}
4242

43-
if (!\is_string($expression)) {
43+
if (!\is_string($expression) && !$expression instanceof \Stringable) {
4444
throw new UnexpectedValueException($expression, 'string');
4545
}
4646

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function validate(#[\SensitiveParameter] mixed $value, Constraint $constr
3636
return;
3737
}
3838

39-
if (!\is_string($value)) {
39+
if (!\is_string($value) && !$value instanceof \Stringable) {
4040
throw new UnexpectedValueException($value, 'string');
4141
}
4242
$passwordStrengthEstimator = $this->passwordStrengthEstimator ?? self::estimateStrength(...);

0 commit comments

Comments
 (0)