File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -736,20 +736,13 @@ Validating Object With Inheritance
736736When you validate an object that extends another class, the validator
737737automatically validates constraints defined in the parent class as well.
738738
739- .. caution ::
740-
741- Note that overriding a property with others constraints in a child class
742- will not remove the constraints defined in the parent class on that same
743- property.
744- Instead, the constraints will be merged for that property.
745- This is related to Java Language Specification.
746-
747- .. tip ::
739+ **The constraints defined in the parent properties will be applied to the child
740+ properties even if the child properties override those constraints **. Symfony
741+ will always merge the parent constraints for each property.
748742
749- If you want to override constraints defined in the parent class, you should
750- define them in a different validation group instead and validate the object
751- with that group.
752- See :doc: `Validation Groups </validation/groups >` for more information.
743+ You can't change this behavior, but you can overcome it by defining the parent
744+ and the child contraints in different :doc: `validation groups </validation/groups >`
745+ and then select the appropriate group when validating each object.
753746
754747Debugging the Constraints
755748-------------------------
You can’t perform that action at this time.
0 commit comments