7

I guess the answer is no, as all references to Bean Validation in the documentation are related to the server side.

Is there any support for Bean Validation on the client's side? So that I can validate my entities before even sending them to the server.

Anish B.
  • 9,111
  • 3
  • 21
  • 41
antonro
  • 449
  • 2
  • 4
  • 10

2 Answers2

3

EDIT

You can use Apache Commons Validator which is part of JSR-303 implementations

Apache Commons Validator provides the building blocks for both client side validation and server side data validation. It may be used standalone or with a framework like Struts.

Or use relevant proprietary client-side solution

JSR-303 doesn’t cover client-side validation, so web frameworks supporting this JSR need to come up with proprietary client-side solutions. Tapestry provides client-side validation for the following JSR-303 constraints

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • Strange, as JPA "client"/ EntityManager is supported. And neither Jackson nor Spring WebClient provide any out-of-the-box integration? – Puce Oct 23 '19 at 14:20
  • The question (title) was about Spring WebClient. It shouldn't depend on the device type, should it? – Puce Oct 23 '19 at 14:23
0

You can call validator manually:

@Autowired
private final SmartValidator validator;

BeanPropertyBindingResult errors = new BeanPropertyBindingResult(entity, "entity");
validator.validate(entity, errors);
if (errors.hasErrors()) {
    //...
}
Nick
  • 3,691
  • 18
  • 36