Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Validator for Java Beans

 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the implementations of JSR-303, Bean validation. For example, the Hibernate validator or even the agimatec-validation
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use xml if you want to. Annotations, isn't mandatory. See chapter-7 of the Bean Validation spec.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

its seems only Hibernate Validator 4.x is fully compliant with JSR 303: Bean Validation and previous releases were not.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jai .. in-fact i was'nt clear either.
 
I found some pretty shells, some sea glass and this lovely tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic