Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] Allow Nested Valid Constraint #49117

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
Closed

[Validator] Allow Nested Valid Constraint #49117

wants to merge 1 commit into from

Conversation

rodnaph
Copy link
Contributor

@rodnaph rodnaph commented Jan 26, 2023

Removes the restriction that the Valid constraint cannot be nested inside a Composite constraint.

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

My use case is attempting naively to use Valid with a When constraint, like so...

#[Constraint\When(expression: 'some condition', constraints: [new Constraint\Valid()])]
public Foo $foo;

ie. Only descend to validate this property when some condition is met, in my case when another boolean field is true.

This functionality seems to have been added some time ago and while I can see other constraints have been added with the same restriction, I can't see the precise reason so I'm hoping something has changed in the meantime. A warning sign is that the groups property is not defined on the Valid constraint when used this way, hence the addition of the default. Any pointers appreciated.

Apologies if this case has been brought up before but I couldn't find an issue, or if there is a workaround or better approach. I'll hold on updating tests until this can be verified or rejected.

removes the restriction that the Valid constraint cannot be nested
inside a composite constraint.
@carsonbot
Copy link

It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you.

Cheers!

Carsonbot

@WebMamba
Copy link
Contributor

WebMamba commented Jan 26, 2023

looks like this came from this PR : #11505. But I don't see the reasons as well. This is super old code, so there are reasons. 😁

@nicolas-grekas nicolas-grekas modified the milestones: 6.3, 6.4 May 23, 2023
@owsy owsy closed this by deleting the head repository Nov 3, 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