Uploaded image for project: 'Hibernate Validator'
  1. HV-902

Cascading validation does not work on classes which implement Iterable.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 5.1.1.Final
    • Fix versions: 5.1.2.Final, 5.2.0.Alpha1
    • Components: engine
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      I had a class which implemented Iterable, but also had constraints I expected to be validated. Everything worked as expected when validating this class directly, but when this class was part of a cascading validation, it's annotated fields were never validated. I found the code in org.hibernate.validator.internal.engine.ValidatorImpl#createIteratorForCascadedValue which looks culpable. If the given type is Iterable, only the elements in the result of invoking iterator() will be validated. I think it should also validate any annotated members of the type itself. In other words, I don't think being iterable should preclude having constraints validated. I've attached a simple test case illustrating the problem. Thank you.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: