Skip to content

fix(symfony): fix property restrictions for root resource with dynamic validation groups #7184

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

Open
wants to merge 1 commit into
base: 4.1
Choose a base branch
from

Conversation

c1tru55
Copy link
Contributor

@c1tru55 c1tru55 commented May 29, 2025

Q A
Branch? 4.1
Tickets n/a
License MIT
Doc PR n/a

similar to #6908

#[ApiResource(
    validationContext: [
        'groups' => ValidationGroupsGenerator::class,
    ],
)]
class Foo

If root resource has dynamic validation groups via \ApiPlatform\Symfony\Validator\ValidationGroupsGeneratorInterface service - validation groups for it in ValidatorPropertyMetadataFactory are evaluated as plain array ['\App\Validator\ValidationGroupsGenerator'] and as a result no constraint is found for these validation groups.

use same checks as in https://github.com/api-platform/core/blob/main/src/Symfony/Validator/Validator.php#L39-L45

@c1tru55 c1tru55 force-pushed the fix-property-restrictions-for-root-resource-with-dynamic-validation-groups branch from b14513f to 29c4eb7 Compare May 29, 2025 09:53
@soyuka
Copy link
Member

soyuka commented Jun 2, 2025

Nice catch, thanks! We could move this code to a trait to share the code wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants