RE: [PEAR-DEV] Mod 10 for Payment package?
| From: | Joe Stump | Date: | Wed, 17 Sep 2003 15:27:35 +0000 |
| Subject: | RE: [PEAR-DEV] Mod 10 for Payment package? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-21638@lists.php.net to get a copy of this message | ||
I guess I like my error checking to be even more complex. I usually
return PEAR_Error instances and use them as such:
$result = Validate::creditcard('20987280976262');
if(PEAR::isError($result))
{
die($result->getMessage());
}
I can change the default behavior though ...
--Joe
--
Joe Stump
http://www.joestump.net
"How would this sentence be different if pi equaled 3?"
-----Original Message-----
From: Tomas V.V.Cox [mailto:cox@idecnet.com]
Sent: Wednesday, September 17, 2003 6:24 AM
To: Pierre-Alain Joye
Cc: Stefan Neufeind; pear-dev@lists.php.net; joe@joestump.net;
makler+pear@man.torun.pl
Subject: Re: [PEAR-DEV] Mod 10 for Payment package?
On Wednesday, September 17, 2003 10:49, Pierre-Alain Joye wrote:
> On Wed, 17 Sep 2003 10:41:29 +0200
> "Stefan Neufeind" <stefan@neufeind.net> wrote:
>> For sure your contributions are always welcome. But maybe Joe could
>> have a look at it, compare it with his ideas and if he has further
>> contributions / checks / ... could streamline all the up-coming
>> ideas?
> Yeah go ahead to commit changes according to our discussion. Once you
> are ready mail me, then I'll launch a new alpha release.
> It will be easier for you to get feedbacks.
> One important point about Validate is it will always return
> true/false. It is the main idea behind it. However subclasses may
> provide more informations about what is wrong in a given data. Tomas,
> agreed?
If there will be functions returning error codes, I guess that would be
better to normalize this situation to all functions.
If error codes starts from -1 to -n, the look will be:
Simple check:
if (Validate::foo('bar') < 0) {
die("invalid 'bar'");
}
Complex check:
$error = Validate::foo('bar');
if ($error == VALIDATE_FOO_TOO_SHORT) {
die("'$bar' was too short");
// or even provide error messages
die(Validate::getMessage(VALIDATE_FOO_TOO_SHORT));
// other idea
die(Validate::getLastErrorMessage());
}
I'd use VALIDATE_<FUNCTION>_MSG for the convention. The objective of the
class was simplicity of checking, but I agree that many people need or
want to have precise info about the error.
It's up to you Pierre, I'm just giving ideas :)
--
Tomas V.V.Cox mailto:cox@idecnet.com
--
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php