Skip to content
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

[Form] group constraints when calling the validator #34464

Merged
merged 1 commit into from Nov 21, 2019

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Follow up of #34081
Spotted during the workshop at SymfonyCon, while trying to fix deprecation notices on symfony-demo:
the Form component currently passes constraints one by one for validation, effectively preventing the validator from taking care of cross-constraints dependencies.

This PR fixes it.

This will prevent ppl from having to fix things like

Using the "Symfony\Component\Validator\Constraints\Length" constraint with the "min" option without setting the "allowEmptyString" one is deprecated and defaults to true. In 5.0, it will become optional and default to false.

@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Nov 20, 2019
@nicolas-grekas nicolas-grekas changed the title [Form] group contraints when calling the validator [Form] group constraints when calling the validator Nov 20, 2019
@@ -97,6 +99,10 @@ public function validate($form, Constraint $formConstraint)
}
}
}

foreach ($groupedConstraints as $group => $constraint) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- constraint
+ constraints

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would override the $constraints variable used above.

Copy link
Contributor

@dmaicher dmaicher Nov 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name it $constraintsInGroup or so? Slightly confusing otherwise 🙈

nicolas-grekas added a commit that referenced this pull request Nov 21, 2019
…as-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[Form] group constraints when calling the validator

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Follow up of #34081
Spotted during the workshop at SymfonyCon, while trying to fix deprecation notices on symfony-demo:
the Form component currently passes constraints one by one for validation, effectively preventing the validator from taking care of cross-constraints dependencies.

This PR fixes it.

This will prevent ppl from having to fix things like
> Using the "Symfony\Component\Validator\Constraints\Length" constraint with the "min" option without setting the "allowEmptyString" one is deprecated and defaults to true. In 5.0, it will become optional and default to false.

Commits
-------

d15f77f [Form] group constraints when calling the validator
@nicolas-grekas nicolas-grekas merged commit d15f77f into symfony:4.4 Nov 21, 2019
This was referenced Nov 21, 2019
@nicolas-grekas nicolas-grekas deleted the form-group-constraints branch November 26, 2019 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants