On Sep 7, 2007, at 3:03 PM, Jim Spath wrote:


Ok, I will try implementing the address check as a validator, but I guess I'm still a little unclear on when a given check should be run as a constraint vs a validator. I have read the docs, but it doesn't seem to be well defined.

Generally a constraint is used for more low level information, and validators for higher-level stuff. A good example is email addresses, an Email constraint would check for things like "is this a string", "does it contain an @ sign", "does it end with a valid top- level domain", and other things applicable to all email addresses. Validators are usually used for more business-logic level things, like a registration form might have an email validator that checks to make sure the email address being registered doesn't already exist in the database.

Also, the address validation we are using can auto-correct addresses in certain cases. Is it possible for a validator (or a constraint) to modify parameter values if necessary?

The validator gets a reference to the parameters as a second argument, so it is possible to modify the values, but I'm not sure how much work that would be, since you might have to deal with situations like if the field has an Inflator, the value will already be inflated by the time the Validator is called, and you might have to inflate it again if you are modifying it...

1;
--
Jason Kohles
[EMAIL PROTECTED]
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to