Skip to content

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Feb 20, 2014

This is still the most difficult part of the validation groups and we
don't put much attention on it. I've refactored it a bit after the
really great explaination of @webmozart.

For more information see: symfony/symfony#10287 (comment)

Q A
Doc fix? yes
New docs? yes
Applies to all
Fixed tickets -

@wouterj
Copy link
Member Author

wouterj commented Feb 20, 2014

btw, also fixed some grammar in the Group Sequence Provider section

@lyrixx
Copy link
Member

lyrixx commented Feb 20, 2014

Thank you very much for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this is the wrong order. All constraints belong to the "Default" group first and foremost. "User" is just an alias for the constraints in the "Default" group of the User class. That means, for example:

class User extends Person
{
    /**
     * @Assert\Valid
     * @Assert\Type("Acme\Address")
     */
    private $address;
}
  • When I validate a User object in the "Default" group, all default constraints of both the User and the Address will be validated.
  • When I validate it in the "User" group, only the default constraints of the User class (and superclasses) will be executed
  • When I validate it in the "Address" group, only the default constraints of the Address class will be executed.
  • When I validated it in the "Person" group, only the default constraints of the Person class (and superclasses) will be executed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, you should use CamelCaps notation for group names.

Copy link
Member Author

Choose a reason for hiding this comment

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

About your first comment: Thanks a lot for creating such a nice real world examples! :) It helps me a lot to understand the topic. I think I've covered it now in the updated list.

And your second comment: I can't see a place where I don't use CamelCaps?

@webmozart
Copy link
Contributor

Thanks for clarifying @wouterj!

@weaverryan
Copy link
Member

This is much better explained! Though I'll admit, the subtleties between the Default and User stuff makes my head spin a little bit still.

weaverryan added a commit that referenced this pull request Mar 8, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

Clarified Default and ClassName groups

This is still the most difficult part of the validation groups and we
don't put much attention on it. I've refactored it a bit after the
really great explaination of @webmozart.

For more information see: symfony/symfony#10287 (comment)

| Q   | A
| --- | ---
| Doc fix? | yes
| New docs? | yes
| Applies to | all
| Fixed tickets | -

Commits
-------

b6357fa Updated after review of @webmozart
2330cd8 Clarified Default vs ClassName groups
@weaverryan weaverryan merged commit b6357fa into symfony:2.3 Mar 8, 2014
@wouterj wouterj deleted the improve_default_group branch March 8, 2014 18:35
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.

4 participants