Validation class method

From: Date: Thu, 06 Jun 2002 15:40:54 +0000
Subject: Validation class method
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6745@lists.php.net to get a copy of this message
Tomas, I've written a US SSN (social security number) validator for my own uses. I thought you might want to include it in the validation class. -timmyg /** * Validates a string to see if it is a valid social security number. * Returns true on valid social security number. * @access public * @parameter string The string to test. * @returns boolean True on valid ssn, False otherwise. * @author Tim Gallagher<timg@sunflowerroad.com> */ function ssn($inbound) {
    if (strpos($inbound, "-") === FALSE) {
        // the social security number has no dashes.  check length and numericity only.
    } else {
        //get rid of the dashes, then check.
        $inbound = implode("",explode("-",$inbound));
    }; // end if
    if ( ereg("^([0-9]{9})$", $inbound )) {
        return TRUE;
    } else {
        return FALSE;
    }; // end if
} // end method

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