Re: Validation functions

From: Date: Sun, 23 Jun 2002 13:46:11 +0000
Subject: Re: Validation functions
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7307@lists.php.net to get a copy of this message
Brent Cook wrote: > > On Sun, 23 Jun 2002, Alan Knowles wrote: > > > This is going to cause a few more problems than it solves.. > > > > Imagine doing database code after setting the error handling to numerical.. > > - it's going to break all your error testing for the database code if > > you forget to turn error back to object based.. > > > > Is there some reason why errors where designed to be passed around > > rather than stored and requested..? > > > > the Validate stuff looks like a perfect place to use something like > > > > if (!Validate:number(........)) { > > $error = PEAR::getLastError(); > > $errors .= $error->getMessage(); > > } > > +1 here > > if you're going to bother catching an error, you have to go through as > much hoopla in the current system too; e.g. > > $error = Validate::number(.....); > if (PEAR::isError($error)) { > $error = $error->getMessage(); > } > > It's four lines either way, but the adantage of just passing a bool is > that an object isn't created every time there's an error, passed and > copied several times. This makes more sense to me with validate > especially, since a validation function returning a false value is > definitely _not_ an exceptional event. You expect it to return false > because of the nature of validation. We can not use $error->getMessage() because there is no error text message! We can't just put english text messages because in this class the errors have to be returned to the user. You know how difficult would be to match all languages and styles there are out there. Big -1. Again. Toams V.V.Cox

« previous php.pear.dev (#7307) next »