Skip to content

Commit cf164e3

Browse files
committed
minor #18747 [Validator] add section for overridden properties (Valmonzo)
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] add section for overridden properties Fixes #14784. This is my first contribution, hope I did right. Thanks `@HeahDude` for your help 🙏🏽 Commits ------- 97ccd6c [Validator] add section for overridden properties
2 parents 61fcb40 + 97ccd6c commit cf164e3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

validation.rst

+21
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)