Skip to content

Commit da9e3b7

Browse files
committed
Reword
1 parent cf164e3 commit da9e3b7

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

validation.rst

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -736,20 +736,13 @@ Validating Object With Inheritance
736736
When you validate an object that extends another class, the validator
737737
automatically 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

754747
Debugging the Constraints
755748
-------------------------

0 commit comments

Comments
 (0)