Skip to content
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

Clarified Default and ClassName groups #3593

Merged
merged 2 commits into from
Mar 8, 2014

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.

and is considered the ``Default`` group. (This group is useful for
* ``User`` - contains the constraints that belong to no other group;

* ``Default`` - equivalent to the ``User`` group (This group is useful for
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