Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
Commons validation.xml only works for depends="required" Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Commons validation.xml only works for depends="required"


    I am using spring 2.5.6 and am attempting to integrate commons validator so that I can have declaritive validation using validation.xml, validator-rules.xml

    I have followed the instructions at the following

    and have validator-rules.xml and validation.xml in place.

    The problem is that the only validator that seems to trigger is depends="required". None of the others do. For example if I have depends="float" or depends="date" the validators just seem to get bypassed and the erroneous input results in java errors.

    Ive searched the forums extensively but cannot find a solution. Can anybody give me some pointers?


  • #2
    In further experimentation I have noticed the following. All of the validators work fine provided the field of the underlying bean is a string. It appears as though the spring modules is doing things in the wrong order, i.e. it appears to be doing
    1) attempt to populate the bean with submitted data
    2) validate the submitted data

    A more logical order would be
    1) validate the submitted data
    2) attempt to populate bean with submitted data

    Has anyone else come across this strange behaviour?


    • #3
      Ive made the discovery that commons validation is not required to check that e.g. a value is a float or a date. Instead you rely on spring binding errors and have a message in

      e.g. to handle all invalid dates:{0} is an invalid date. Use format DD/MM/YYYY.

      However the only issue with this is that {0} will get populated with the field name, e.g. retirementDate:

      retirementDate is an invalid date. Use format DD/MM/YYYY.

      If you wanted something more user friendly you would need

      typeMismatch.retirementDate=Retirement Date is an invalid date. Use format DD/MM/YYYY.