Skip to content

[Validator] [Validation] Add idiomatic way to check if there constraint violations #15983

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

Closed
wants to merge 1 commit into from

Conversation

reecefowell
Copy link

The ConstraintViolationList class cannot be used with PHP's built-in function empty(...) because it is an object, so we have to use the non-idiomatic count($violationList) === 0 or $violationList->count() === 0.

It would be better to have a more idiomatic way to determine if any violations exist via an isEmpty() method.

Relevant PR symfony/symfony#43643

The ConstraintViolationList class cannot be used with PHP's built-in function empty(...) because it is an object, so we have to use the non-idiomatic count($violationList) === 0 or $violationList->count() === 0.

It would be better to have a more idiomatic way to determine if any violations exist via an isEmpty() method.

Relevant PR symfony/symfony#43643
@reecefowell reecefowell requested a review from xabbuh as a code owner October 21, 2021 23:30
@carsonbot carsonbot added this to the 5.4 milestone Oct 21, 2021
@xabbuh xabbuh added the Waiting Code Merge Docs for features pending to be merged label Oct 22, 2021
@carsonbot carsonbot modified the milestones: 5.4, next Oct 22, 2021
@carsonbot carsonbot changed the title [Validation] Add idiomatic way to check if there constraint violations [Validator] [Validation] Add idiomatic way to check if there constraint violations Oct 22, 2021
@nicolas-grekas
Copy link
Member

Closing in favor of #16029, thanks for the PR.

javiereguiluz added a commit that referenced this pull request Oct 28, 2021
…s (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[Validator] [Validation] improve code for counting errors

Replaces #15983
Follows the discussion at symfony/symfony#43643

Commits
-------

3cae3a1 [Validation] improve code for counting errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Review Validator Waiting Code Merge Docs for features pending to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants