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

Skip to content

[Validator] All validation groups are not used on embedded constraints in a collection constraint #17675

Closed
@blazarecki

Description

@blazarecki

Hi,

I don't know if it's a bug but it seem that all embedded constraints of a collection constraint are not applied when using validation groups.

I think that only the first validation group passed to the validator is used and the other are omitted.

With the following example if $config is equal to ['foo' => 'a'] then with validation groups:

  • ['foo', 'bar', 'baz'] we have 0 violation (NotBlank)
  • ['baz', 'bar', 'foo'] we have 1 violation (Lenght(min="4"))
  • ['bar', 'baz', 'foo'] we have 1 violation (Lenght(min="2"))
    /**
     * @Collection(
     *     fields={
     *          "foo" = {
     *              @NotBlank(groups={"foo"}),
     *              @Length(min="2", groups={"bar"}),
     *              @Length(min="4", groups={"baz"})
     *          }
     *     }
     * )
     */
    public $config;

Here the complete gist with the tests : https://gist.github.com/blazarecki/5dcb754be22dae4f0e53

Any idea ?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions