Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31850

Options for unified Java/JSON validation?

Newsgroups comp.lang.java.programmer
Date 2015-06-24 03:04 -0700
Message-ID <1ea33386-281d-4f24-805a-212fb13d1e57@googlegroups.com> (permalink)
Subject Options for unified Java/JSON validation?
From rupertlssmith@googlemail.com

Show all headers | View raw


I'm looking at the issue of how to define validations on a domain model in Java, and have those flow through to the UI, so that screens can validate forms as JSON, that are instances of the some model.

In Java, the standard is JSR303. In JSON there is no standard, but jsonSchema is a possibility. Outwith that there seem to be many, many more or less developed systems and standards.

It looks like one of the most complete systems for unifying validation accross JSR303 and javascript framework is valdr, for adding validation to AngularJS forms, based on JSR303. valdr has a JSR303 plugin, but it would seem to rely on the annotations only, it does not seem to support the ability to dynamically add rules based on context?

There are some issues with systems that derive rules from JSR303... If they rely solely on the annotations in Java code, they will miss validation rules that are added more dynamically, for example through the API offered by the Hibernate validator 303 implementation. These are features I will need, since the validation rules change, dependant on context.

Here is the required feature set I need:

Ability to define core validations using JSR303 annotations.
Ability to add validations on top of the core validations, for different situations. For example, core validation may simply say a field is max length 100. In a particular state, a rule may be added to say that field is also mandatory.
Ability to present validations in some kind of schema to a javascript framework. jsonSchema would do.
Ability to present validation errors from the Java in a format such that the front end can re-display the form with the errors, as some validation rules will require a round-trip to the back-end.

Somewhere in the myriad of validation frameworks, do you know of any that can meet the feature set I need?

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Options for unified Java/JSON validation? rupertlssmith@googlemail.com - 2015-06-24 03:04 -0700

csiph-web