Description
When I first had the need to use validation groups I accidentally stumbled across the GroupSequenceProvider until I found what I actually wanted to do.
What I like about the GroupSequenceProvider is that you actually bind the validation logic to the entity configuration.
http://symfony.com/doc/current/book/validation.html#group-sequence
However with the validation groups it is not tied to the entity. I think a common use case is to validate based on the state of an entity. If you only validate your entities based on Forms you are unlikely to have any issues. However the entity validation logic is tied to the form configuration.
I would suggest an Approach with an Interface lets call it ValidationGroupsProdviderInterface
with a method ValidationGroupsProdviderInterface::getValidationGroups()
. The Form component could rely on this as well, the logic of the groups is tied to the entity and the risk of missing proper validation is reduced.
One concern which comes to my mind is the fact that the Validate method of the Validator accepts groups as parameters. And we also might travers through relations with the Valid() constraint. So the question would be when to use which groups.
What do you think about this?