Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Downsides of JSR-303 Bean Validation

  • No guarantee of the order of validation in one field
  • No guarantee of the order of fields to be validated
  • No guarantee of the order of error messages
  • Can't use the result of validation in business logic
    • e.g. it will become a bottleneck to implement "save to temporary store when it has errors" or "do correlation validation if it passes all single-field validations"
  • Unclear behavior in formatting annotations when an error occurred in the validation

It seems like JSR-303 assumes:

  • Two or more validations must be wrapped into one annotation
  • Display only one error message per input field
  • Error messages are always displayed next to the input field