1

I've a RESTful web applications where all the server side validations are in place. For example, there is a request object for creating saleOrder:

public class WsSaleOrder {
    @NotNull
    @Length(max = 45)
    private String code;

    @Length(max = 45)
    private String displayOrderCode;

    @NotNull
    @Length(max = 45)
    private String customerCode;

    @Length(max = 100)
    private String customerName;
    private String channel;

    @Email
    @Length(max = 100)
    private String notificationEmail;
    ....
}

When createSaleOrder api is invoked, the request object is validated and validation errors are returned. Now I want to create a UI form for this and I would like to have all validations present on client side as well from usability perspective.

Is there a standard way by which I can dynamically pass this validation profile to the client by reading the annotations present on the request object.

Jeevan Patil
  • 6,029
  • 3
  • 33
  • 50
Sunny Agarwal
  • 1,451
  • 4
  • 18
  • 36
  • possible duplicate of [JSR 303 Bean Validation + Javascript Client-Side Validation](http://stackoverflow.com/questions/2513863). – lefloh Sep 03 '14 at 10:56
  • 1
    There is no standard way. Here is a [github project](https://github.com/adorsys/beanval2json) where I export the beanval-attributes to JSON. – lefloh Sep 03 '14 at 10:57

0 Answers0