-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Allow ConstraintViolation::__toString()
to expose codes that are not null or emtpy strings
#29375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Validator] Allow ConstraintViolation::__toString()
to expose codes that are not null or emtpy strings
#29375
Conversation
@@ -79,13 +79,13 @@ public function __toString() | |||
} | |||
|
|||
$propertyPath = (string) $this->propertyPath; | |||
$code = $this->code; | |||
$code = trim($this->code); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trimming is a new behavior, which IMHO is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point, and I agree. My concern was originated by the absence of delimiters around the printed code, so I thought that readability could be improved trimming any undesired blankspace around the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the delimiter is (code
and )
:)
undesired blankspace
we don't know that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean cases like
(code )
I think it is not clear which space comes from the dumped message and which one comes from the actual code, but I'm pretty sure this is an edge case that we can ignore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(for 3.4 as 2.8 is EOLed now)
Updated base to target 3.4. |
… that are not null or emtpy strings
1cbe5dc
to
7bb0fb5
Compare
Thank you @phansys. |
…xpose codes that are not null or emtpy strings (phansys) This PR was squashed before being merged into the 3.4 branch (closes #29375). Discussion ---------- [Validator] Allow `ConstraintViolation::__toString()` to expose codes that are not null or emtpy strings |Q |A | |--- |---| |Branch |2.8| |Bug fix? |yes| |New feature? |no | |BC breaks? |no | |Deprecations?|no | |Tests pass? |yes| |Fixed tickets|n/a| |License |MIT| |Doc PR |n/a| Allow to expose `0` or `"0"` validation codes. Commits ------- 7bb0fb5 [Validator] Allow `ConstraintViolation::__toString()` to expose codes that are not null or emtpy strings
Allow to expose
0
or"0"
validation codes.