[html-formfu] some questions

Jason Kohles email at jasonkohles.com
Sat Sep 8 00:42:24 GMT 2007

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...

Jason Kohles
email at jasonkohles.com
"A witty saying proves nothing."  -- Voltaire

More information about the HTML-FormFu mailing list