8000 [Validator] Allow single constraint to be passed to the `constraints` option of the `When` constraint by alexandre-daubois · Pull Request #50425 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Allow single constraint to be passed to the constraints option of the When constraint #50425

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

Merged

Conversation

alexandre-daubois
Copy link
Member
@alexandre-daubois alexandre-daubois commented May 25, 2023
Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets NA
License MIT
Doc PR Todo

It would be nice for the DX to allow passing a single constraint to When, allowing to write the following:

final class MyClass
{
    public string $type;

    #[Assert\When(
        expression: 'this.type === ...',
        constraints: new Assert\NotNull()
    )]
    public ?int $thickness = null;
}

@chalasr
Copy link
Member
chalasr commented May 25, 2023

Symfony doesn't do backward-incompatible changes without deprecating first, this should target 6.4 and provide BC layers if/where needed.

@alexandre-daubois
Copy link
Member Author

@chalasr Nicolas and Christian are giving me instructions for the same issue here. I'm having a look, thanks!

@chalasr
Copy link
Member
chalasr commented May 25, 2023

AFAICT there is no BC break here, this should be fine as-is on 6.4.

@xabbuh xabbuh modified the milestones: 7.0, 6.4 May 25, 2023
@OskarStark
Copy link
Contributor
OskarStark commented May 25, 2023

AFAICT there is no BC break here, this should be fine as-is on 6.4.

I agree, as it is widening the type

@alexandre-daubois alexandre-daubois force-pushed the validator-when-single-constraint branch from 81a6786 to af04cb5 Compare May 25, 2023 11:57
@alexandre-daubois alexandre-daubois changed the base branch from 7.0 to 6.4 May 25, 2023 11:57
@alexandre-daubois
Copy link
Member Author

I thought again about it, you're right, it shouldn't cause any issue as it is in the constructor. Thank you both 🙏

@nicolas-grekas
Copy link
Member

This PR should be put on hold until we settle on #50396 (comment)

@nicolas-grekas nicolas-grekas force-pushed the validator-when-single-constraint branch from af04cb5 to c59a629 Compare June 21, 2023 16:21
@nicolas-grekas
Copy link
Member

Thank you @alexandre-daubois.

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.

6 participants
0