Validating Collections - #fields.hasErrors

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Validating Collections - #fields.hasErrors

I have a collection of complex objects

List<Foo> foos = Lists.newArrayList();

class Foo{

String description;


I have it bound to a text field like

*{foos[__${arrStat.index}__].description} which is working fine.  My issue is with error messaging.  #fields.hasError is not finding the error in the collection. When Hibernate Validator validates the collection it's setting the PropertyPath as foos.[4].description instead of foos[4].description.  I'm not really sure if this is a thymleaf issue or a jsr303/hibernate/spring issue.  Has anyone else seen this?
Reply | Threaded
Open this post in threaded view

Re: Validating Collections - #fields.hasErrors


Maybe it's a bug in your specific version of the Hibernate Validator...

I checked this in the "stsm" thymeleaf example application, adding:

  - @Valid to the SeedStarter.rows field
  - @NotNull to the Row.seedsPerCell field

And trying to save a seed starter with one row with no value for its "seeds per cell" field. The resulting FieldError is assigned to "rows[0].seedsPerCell"

Versions: Spring 3.0.7, validator-api 1.0.0.GA, hibernate-validator-annotation-processor 4.1.0.Final