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?
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.
@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.
"..., 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.
You can try Hibernate Validator which is in fact the reference implementation for JSR 303: Bean Validation. BTW, it is still in beta.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With