17.1. Commons-Validator framework

After having evaluated several validation frameworks, we finally decided to integrate Apache's Commons-Validator into DbForms. This framework is capable of performing basic server-side validations such as verifying if a field is required, or that it matches a regular expression. Different validation rules can be defined for different locales. Although the framework already provides several basic validation routines, custom validation routines can be created and added to the framework.

This framework also supports client-side validation through the generation of JavaScript methods. Use of these methods is enabled via an attribute setting within dbForms.

Commons-validator uses two xml files for setting up validation:

  1. Validator-rules.xml

    Contains general validation rules.

  2. Validation.xml

    This file is used to associate validation rules to table fields.