valdr Bean Validation

Build Status Coverage Status Maven Central License

Bean Validation (JSR 303) plugin for valdr, the new AngularJS Model Validator.


valdr Bean Validation parses Java model classes for Bean Validation constraints (aka JSR 303 annotations) and extracts their information into a JSON document to be used by valdr. This allows to apply the exact same validation rules on the server and on the AngularJS client.



Check out the demo for usage samples of both CLI client and Servlet.


CLI client

Example of Maven integration:

          <!-- optional, if omitted valdr-bean-validation.json is expected at the root of the class path -->
          <!-- optional, overrides any 'outputFile' which may have been set in the above config file -->


Example of web.xml:

  <servlet-name>valdr Bean Validation Servlet</servlet-name>
  <!-- if omitted valdr-bean-validation.json is expected at the root of the class path -->

Dependency on valdr

valdr Bean Validation is dependent on valdr in two ways:

To indicate which valdr version a specific valdr Bean Validation version supports there's a simple rule: the first digit of the valdr Bean Validation version denotes the supported valdr version. Version 1.x will support valdr 1. This means that valdr Bean Validation 1.x+1 may introduce breaking changes over 1.x because the second version digit kind-of represents the "major" version.

Mapping of Bean Validation constraints to valdr constraints

The enum defines the mapping of Bean Validation constraints to valdr constraints.

Bean Validation valdr Comment
NotNull required
Min min
Max max
Size size
Digits digits
Pattern pattern Java regex pattern is transformed to JavaScript pattern
Future future
Past past
Email email
URL url proprietary Hibernate Validator (not in Bean Validation spec)


Ask a question on Stack Overflow and tag it with valdr-bean-validation.


MIT © Netcetera AG