I finally got around to adding a few validators I had laying around to incubator. Just some basic stuff like integer, double, regexp and email validators. The project can be found at incubator/Validators. In case you want to use it in a project there is a jar available at
http://dev.itmill.com/browser/incubator/Validators/validators-20080211.jar .
Use like:
TextField tf = new TextField("A textfield");
tf.addValidator(new EmailValidator("{0} is not a valid email address"));
{0} is replaced by the validated value in the error message.
Feel free to contribute more validators to the project!
Great, these are probably the most often needed validators.
I’d like to see client-side validators as well, so that the user would get really-immediate feedback, that is, the user wouldn’t even be allowed to input invalid format. Think of “Pattern Fields”, for example.
It’s of course necessary to have server-side validation as the primary validation.
It’s possible to extend client-side components to add validation, but it would be more convenient if there was a validator interface in the client-side as well. Or a more generic decorator interface.