Jboss.org Reference - buggy examples?


Hi. I started going over the reference page:


And there seem to be some bugs in the code there. They only list Hibernate as references, so here I am:

  1. Section, Example 2.4, last line says “parts[1]…” as the index of the first element in a list, but it should be zero instead of one, correct?

  2., Example 2.7, @MinTorque(100), vs super(100) should NOT create a ConstraintValidation, should it? - there are 5 classes involved so I could be wrong, but I don’t see any math…




Thanks for taking the time to report this and sorry for the delay, I haven’t replied right away and then forgot about it.

  1. The “1” index is correct as the error is coming from the second element of the list (and as the indexes start from 0, the second element of the list is at index 1)
  2. The code is here: https://github.com/hibernate/hibernate-validator/blob/master/documentation/src/test/java/org/hibernate/validator/referenceguide/chapter02/containerelement/custom/MinTorque.java#L23 (our examples are coming from real code). As the comparison is strict, it should throw a violation. But that being said, I agree with you that the example could be more explicit and clear. I’ll change the value in the test. I created https://hibernate.atlassian.net/browse/HV-1572 to track this.