Skip to content

Register and tag validators in container #49779

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 4 commits into from
Closed

Register and tag validators in container #49779

wants to merge 4 commits into from

Conversation

nfragnet
Copy link

Q A
Branch? 6.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #49397
License MIT
Doc PR

This PR register validators related to a constraints having violation messages as services in container and tag them so the TranslatorPass take them into account when extracting constraint messages in attributes.

This PR is a first draft with the solution suggested by @MatTheCat in the related ticket.

It will also extract userland constraint messages if validators are declared as service.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

'alias' => IsbnValidator::class,
])

->set('validator.is_false', IsFalseValidator::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure to want to maintain this big list of services? Maybe the fix should be on the translator component since this is the only issue we founded due to not declared constraints?

Copy link
Author

Choose a reason for hiding this comment

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

I agree with that, this PR is a glimpse of the involvements of a solution going in the way of the original feature taking the postulate that validators were all services

Copy link
Contributor

Choose a reason for hiding this comment

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

I’m not sure since the issue is proof that validator.constraint_validator is unreliable. If a fix is applied to the translator component I think this tag would have to be removed.

Copy link
Author

Choose a reason for hiding this comment

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

Alternative solution in the translator component available here

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah #49785 feels better indeed; it’s not that validator.constraint_validator is unreliable, it’s just that unregistered validators cannot be tagged. But would it be possible to still consider it in TranslatorPass to take userland validators into account?

Copy link
Author

Choose a reason for hiding this comment

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

Answering the question here and closing this PR.

@welcoMattic
Copy link
Member

The alternative solution in #49785 is better than this one. As it was said, maintain a list of all constraints is not a good thing.
Let's close and focus on #49785?

@nfragnet nfragnet closed this Mar 24, 2023
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.

5 participants