Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What java validation library should I use?

I'm kinda stuck on this decision. My project already uses Spring and Spring Blazeds integration but I don't think there will be any real web interface (HTML). I have limited experience with Spring MVC and the Spring validators which are OK, but I've read comments from people suggesting not to use Spring validators outside Spring MVC. What validation framework would you recommend based on personal experience?

like image 604
Vasil Avatar asked Jun 21 '09 17:06

Vasil


People also ask

Is the recommended best practice for input validation?

Just in time validations One of the best practices in form validation is to inform your users when they make an error so they can immediately verify and correct it before they take the next step. This way, you avoid error messages in the input field but also helps users build their confidence in what they are doing.

What is @validated in Java?

@Validated annotation is a class-level annotation that we can use to tell Spring to validate parameters that are passed into a method of the annotated class. and. @Valid annotation on method parameters and fields to tell Spring that we want a method parameter or field to be validated.


2 Answers

"..., but I've read comments from people suggesting not to use Spring validators outside Spring MVC..."

I'd like to see those citations. I've used the Spring DataBinding API outside Spring MVC, and it's terrific. I would say that criticism is unfounded.

Apache Commons Validator is an alternative, but I'd still recommend Spring's DataBinder first. Especially if you're already using Spring. The benefit of switching to anything else is more than offset by the cost of yet another dependency.

like image 146
duffymo Avatar answered Sep 22 '22 19:09

duffymo


You can try Hibernate Validator which is in fact the reference implementation for JSR 303: Bean Validation. BTW, it is still in beta.

like image 26
utku.utkan Avatar answered Sep 23 '22 19:09

utku.utkan