• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java data validation  RSS feed

 
Karan Jain
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • 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
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!