Skip to content

Commit 97ccd6c

Browse files
author
PEHAUT-PIETRI Valmont
committed
[Validator] add section for overridden properties
1 parent a39bbc7 commit 97ccd6c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

validation.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,27 @@ constraint that's applied to the class itself. When that class is validated,
730730
methods specified by that constraint are simply executed so that each can
731731
provide more custom validation.
732732

733+
Validating Object With Inheritance
734+
----------------------------------
735+
736+
When you validate an object that extends another class, the validator
737+
automatically validates constraints defined in the parent class as well.
738+
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::
748+
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.
753+
733754
Debugging the Constraints
734755
-------------------------
735756

0 commit comments

Comments
 (0)