Re: Validation functions

From: Date: Mon, 24 Jun 2002 01:38:55 +0000
Subject: Re: Validation functions
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7317@lists.php.net to get a copy of this message
> > > 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. There must have been a misunderstanding. I wasn't advocating that code snippet, but the one above it. I obviously was not clear; I agree with you. The big thing that we should all remember is that, when all you have is a hammer, everything looks like a nail. Returning PEAR_Error is not always appropriate.; sorry to perpetuate things like this, I'll let the folks with more experience make the final call. - Brent

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