Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +739 to +745
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can get rid of the caution box and write just regular text? What do you think?

The tip below is ok from my side 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was my first intention, but it may deserve to be more highlighted given the potential issues.
Let's wait for other opinions?


.. 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 </validation/groups>` for more information.

Debugging the Constraints
-------------------------

Expand Down