wood burning stoves 2.0*
The moose likes Java in General and the fly likes Validator for Java Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Validator for Java Beans" Watch "Validator for Java Beans" New topic
Author

Validator for Java Beans

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Hi,
I have got multiple properties in Java Bean objects , which i would like to validate via configurable item (XML , property file). Any recommendations for this? Thanks.

P:S Hope i m back to JR.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Take a look at the implementations of JSR-303, Bean validation. For example, the Hibernate validator or even the agimatec-validation


[My Blog] [JavaRanch Journal]
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



Thanks Jai , yep i know about Hibernate validator. And since my application is standalone and the validation also occurs in different layer , need to check on this.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


I seriously doubt the use of annotation as configurable parameter. I couldn't believe how Hibernate validator ( which boasts of having bean validation with annotations) would really help.

Say i have got to validate a field with minimum and maximum characters it could take , i can hibernate built-in annotation like this



But what if my requirement changes as min as 5 , and again as max as 20 ? , does that mean i need to recompile my beans and put them back again. On the other hand , xml works way better to externalize these dependencies. Your thoughts please ?


P:S , since the thread discussion moved more on to Hibernate validator, please feel free to move it to appropriate forum.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

You can use xml if you want to. Annotations, isn't mandatory. See chapter-7 of the Bean Validation spec.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


its seems only Hibernate Validator 4.x is fully compliant with JSR 303: Bean Validation and previous releases were not.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

That's correct, as per that wiki link:
As of version 4.x Hibernate Validator is based on a new code base which is the reference implementation for JSR 303: Bean Validation.


Sorry i did not know you were looking at an earlier release.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Thanks Jai .. in-fact i was'nt clear either.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validator for Java Beans