Some more suggestions:
I'm now starting to write a custom input validator for tapestry that is making use of the hibernate validation framework, so I don't have to keep track of the same validation rules in several places.
One thing that is really needed is a function that checks for possible invalid values before they get set:
Code:
public InvalidValue[] getInvalidValues(T bean, String propertyName, Object value);
(I really needed this and solved it by overriding ClassValidator and adding it by hand...)
At present there is no problem in passing null for the bean (as to check for values before bean creation, e.g. a user registration form), I really hope it doesn't change.
Also it would be nice to have a common place for existing validators, maybe in a hashmap in the ClassValidator class:
Code:
public static ClassValidator getValidatorForClass(Class class);
public static ClassValidator getValidatorForClass(Class class, boolean createNew);
If ClassValidators are threadsafe (I'm not shure about it), could be done like that:
Code:
private static Map<Class, ClassValidator> validators = new HashMap<Class, ClassValidator>();
private static Boolean monitor = new Boolean(true);
public static ClassValidator getValidatorForClass(Class class){
ClassValidator validator = validators.get(class);
if (validator == null) {
synchronized (monitor) {
validator = validators.get(class);
if (validator == null) {
validator = new ClassValidator(class);
validators.put(class, validator);
}
}
}
return validator;
}