Re: Validation class method

From: Date: Thu, 06 Jun 2002 17:14:39 +0000
Subject: Re: Validation class method
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6751@lists.php.net to get a copy of this message
El jue, 06-06-2002 a las 18:33, Brent Cook escribió: > On Thu, 6 Jun 2002, Pierre-Alain Joye wrote: > > > On Thu, 6 Jun 2002 11:05:24 -0500 (CDT) > > Brent Cook <busterb@mail.utexas.edu> wrote: > > > > > That's a good idea. What do you think about this simpler version? > > > > > > function ssn($inbound) > > > { > > > // remove any dashes, spaces, returns, tabs or slashes > > > $inbound = str_replace(array('-','/',' > > > ',"\t","\n"),'',$inbound); > > > > > > // check if this is a 9-digit number > > > return (is_int($inbound) && (strlen($inbound) == 9)); > > > } > > > > > > - Brent > > is "123456789" a valid ssn ? :) > > > > just curious, > > > > pa > > Probably not. I'm looking here for more info. Perhaps this could be a > little less trivial. > > > http://www.privateinvestigatorsoftware.com/articles/social_security.htm > I would preffer to include something more sofisticated too :-) You could easily emulate such functionality with: Validate::string($n, VAL_NUM, 9); One note about validation. Validation IMHO is the action of prechecking the data in the final format one want to store it. The manipulation or error correcting is out of the scope of this class. While we are on it, we could start thinking on how to handle the country specific validation methods. I proposed time ago: Validate/ I18N/ ISO.php and access this classes by: require "Validate/I18N/US.php"; ValidateUS::ssn(..); There were talks about autoload functionality. Well this can be done with the following disadvantages: 1) Need to have all the method definitions in the main class 2) May be problems with clashes (two countries with zip validations, for ex). Tomas V.V.Cox

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