• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

common validator for object validation

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I am currently having some methods which have java objects as input parameters.

say if i have an object called Service (which is an input parameter to a method)

This Service object comprises of 3 member variables -
uri, payload & principal.

All these 3 member variables will be extracted in the above mentioned method & then inserted into the database.
In the database, uri & principal are not null columns so I am checking in the method if the 2 are null in the method itself before invoking the database operation. If they are null I throw a custom exception stating the nullness of mandatory parameters as the reason & do not invoke the database operation at all.

This is with null. I want to build a comprehensive sort of validator which can comprise of null checks, empty string validations etc .

Can someone list some pointers to documents or links where I can find more info on the same

Bye
Mahesh
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apache commons has a validator framework. You might see how that works as an example.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic