Sylvain Wallez wrote:

Now I think that every widget should be able to have validators. Some use cases:
- on a form, to perform some inter-field validations, and even application-level validation if the means to access application data is given to the validator.
- on a repeater, to check e.g. uniqueness of some values among rows
- on a group (i.e. "class", "struct", etc) where some validation between the various widgets of the group may be wanted (actually, a form is a group)


The current ValidationRule interface is not suited for this, as it is really tied to widgets that have a value, which neither form nor repeater have.

So my idea is to introduce a generalized "WidgetValidator" with a single "validate(Widget w, FormContext ctx)" method. The current ValidationRule implementations we have today can then simply become subclasses of a "FieldValidator" abstract class.

We also have to see how validators can have knowledge of the surrounding application environment to perform application-level validation. A discussion between Marc and myself a while ago came to the conclusion that we may use pseudo-fields in a form as value holders, as it would make the contract between the form and the application more visible than by adding attributes to the Form object.

What do you think?


No answer on this? If no one objects, I will implement it as I really need it now.

Sylvain

--
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com




Reply via email to