Monday, March 23, 2009

Validation Processing Flow

Found this while I'm cracking my head on how to do a proper validation.

Given the different kinds of validation on offer, one might ask how they are applied, and what happens when errors are produced at any stage. The following is the general flow:

  1. Required field validation is run first
  2. Perform minimum/maximum length and mask validations
  3. If the field still has no errors, convert to the target type and bind the property to the ActionBean
  4. If the field converted without errors, run any min/max value checks (for numbers)
  5. For fields that have no errors, evaluate expression based validations
  6. If there are still no errors, run custom validation (unless overridden to run with errors)
This strategy is designed to catch the largest possible number of validation errors possible in a single pass. Thus if the user forgets to enter one value, and mis-types another, they will be presented with both errors the first time they submit the form - but they will not be presented with any additional (e.g. minimum length violation) errors for the field that was required but not supplied.

Source: http://www.stripesframework.org/display/stripes/Validation+Reference

No comments:

Post a Comment