Hi,
Java-based UI frameworks typically use javax.validation.Validator#validateValue() which evaluates validity of a given property value before putting it into the actual data model.
If you need to expose constraint information to JavaScript clients, you can use the metadata API (https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#validator-metadata-api) which provides information about all the constraints of given types or properties. Based on that, you could implement a JS library which performs all the validations on the client side (maybe such a library even already exists?). One challenge would be custom constraints with custom validator implementations. In most cases it may be sufficient to provide a fixed set of corresponding JS implementations. Or you define a way of tagging certain constraint types as not to be run on the client side.
Hth,
--Gunnar
_________________ Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/
|