From 97ccd6c6722c4e2e2ff751667a3ea36e6e233dd7 Mon Sep 17 00:00:00 2001 From: PEHAUT-PIETRI Valmont Date: Mon, 14 Aug 2023 09:53:17 +0200 Subject: [PATCH] [Validator] add section for overridden properties --- validation.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/validation.rst b/validation.rst index 33b578216dd..661bf14252e 100644 --- a/validation.rst +++ b/validation.rst @@ -730,6 +730,27 @@ constraint that's applied to the class itself. When that class is validated, methods specified by that constraint are simply executed so that each can provide more custom validation. +Validating Object With Inheritance +---------------------------------- + +When you validate an object that extends another class, the validator +automatically validates constraints defined in the parent class as well. + +.. caution:: + + Note that overriding a property with others constraints in a child class + will not remove the constraints defined in the parent class on that same + property. + Instead, the constraints will be merged for that property. + This is related to Java Language Specification. + +.. tip:: + + If you want to override constraints defined in the parent class, you should + define them in a different validation group instead and validate the object + with that group. + See :doc:`Validation Groups ` for more information. + Debugging the Constraints -------------------------