Now we have the use cases !
Don Brown wrote:
Just to be clear, the approach I feel would be simplest is to add "isValid(Object bean, Field field)"-type methods to each validator. This way, the validators commons-validator provides can be used as they are or front-ended like how Struts' FieldChecks class interacts with them. I've already gone through several validators, adding unit tests as I go, and things are looking good. Before I finish the rest of the validators, however, I want to make sure this is a good idea in the eyes of everyone else.
For example, the new DateValidator looks like this:
public boolean isValid(Object bean, Field field); public boolean isValid(Object bean, Field field, Locale locale); public boolean isValid(String value, String datePattern, boolean strict); public boolean isValid(String value, Locale locale);
The top two methods do four things:
1. Pull the necessary parameters out of field variables (ie "datePattern" out of a field var to be passed to the third method)
2. Extract the field value as a String
3. Return true if the value is blank or null since the field may not be required (the bottom two methods return false in such a case)
4. Delegate handling to the bottom two methods
Any objections?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]