Results 1 to 1 of 1
- 08-20-2012, 04:11 AM #1Member
- Join Date
- Aug 2012
- Rep Power
Apache commons validator, bean properties to validate should all be string?
I was working on apache commons validator latest. Problem explained below.
My Bean is having 2 properties fullName (String) & age (int). Validation "required" on both but age needed to be checked for "integer" as well.
bean.setFullName("Tester"); -----> Will Pass
bean.setAge("Too Old"); ---> "required Pass but "integer" Fail.
results = validator.validate();
Note: Above is possible if age property is String but its not and setAge won't accept String value and throw exception before reaching validator.validate().
Validation should be checked before we set the bean. In above situation I need to make all properties string than in validation.xml check for integer/condition.
How I work with this when my age property is Integer. little confused. Handle bean with date, integer etc?
- By gurpreet.singh in forum Advanced JavaReplies: 1Last Post: 03-23-2011, 07:55 AM
- By msucena in forum XMLReplies: 4Last Post: 11-04-2010, 02:41 PM
- By edwardmluk in forum Java ServletReplies: 1Last Post: 03-06-2009, 04:24 PM
- By aczuczor in forum Web FrameworksReplies: 0Last Post: 07-27-2007, 08:46 AM