• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java data validation

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need to parse a fixed length text file and then do the data validation on it. File can contain 100+ records.
Data validation for each record will typically have:
1) Numeric check, min/max value check, decimal precision check etc.
2) Date check
3) currency code is same in all the amount fields in the record.
4) couple of fields will be validated from the database too...

File level validation:
1)sequence number are in order in the file for each record.
2)seq of record should be header, data --- data , trailer... then again header, data... data, trailer and then finally end.

Whenever there is an error in a field for a record i need to store the error message for the field... and then finally display all the errors for each field in each record rendering an html page.

What can be the a good approach to attack this problem?
Are there any validation framework in java to support this type of validation?

Any help and code is appreciated.

Thanks and regards,
Karan
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Apache Commons Validator might do the validation bits. I'm sure it won't do all those things you need, but you might be able to plug in your own validators and still use the framework.

If I had to do this more than once ... I'd make a metadata file that has something like

for each field. Your program can read that first, then extract the fields from each record and call the appropriate validator(s).
[ July 13, 2007: Message edited by: Stan James ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic