-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Validator] Add a constraint to sequentially validate a set of constraints #13206
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] Add a constraint to sequentially validate a set of constraints #13206
Conversation
783fda7
to
4a0255f
Compare
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.
Looks really good, thanks. Just some minor comments
bc09631
to
fdd9bad
Compare
I've applied your suggestions, thank you 👍 |
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.
Another round :)
fdd9bad
to
29a6194
Compare
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.
Nice! Thanks
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.
👍🏻
* @Assert\NotBlank(), | ||
* @Assert\Type("string"), | ||
* @Assert\Length(min=10), | ||
* @Assert\Regex(Place::ADDRESS_REGEX), |
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.
One minor, do you have a regex pattern which can be added? Do we really need the regex here? If yes, should we add the constant to the code example?
But adding a regex is maybe distracting, could we inline the pattern or is it anyway to complex?
What do you think of removing it completely from the example?
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'd prefer to avoid adding a regex pattern. I used (but didn't show) a constant for the reason mentioned: the regex isn't important on its own and would be distracting.
I think the @Regex
in the example deserve a purpose to demonstrate the step-by-step application of the rules, as it'll usually fail hard despite being used conjointly with Type
without the Sequential
constraint. But @Length
demonstrate the same, so if you really prefer, I can remove it indeed.
Thank you Maxime. |
…+ target guards (ogizanagi) This PR was merged into the 5.1-dev branch. Discussion ---------- [Validator] Allow Sequentially constraints on classes + target guards | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | todo in symfony/symfony-docs#13206 if not merged yet There is no reason to limit this constraint to properties, so let's add classes as targets. Additionally, let's ensure embedded constraints matches allowed targets too. Commits ------- 1e02a96 [Validator] Allow Sequentially constraints on classes
…+ target guards (ogizanagi) This PR was merged into the 5.1-dev branch. Discussion ---------- [Validator] Allow Sequentially constraints on classes + target guards | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | N/A <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | todo in symfony/symfony-docs#13206 if not merged yet There is no reason to limit this constraint to properties, so let's add classes as targets. Additionally, let's ensure embedded constraints matches allowed targets too. Commits ------- 1e02a96286 [Validator] Allow Sequentially constraints on classes
closes #13076