Skip to content
Browse files

Fixed $check for SSN of Brazil.

  • Loading branch information...
1 parent 596b863 commit 7d7376ab757b71504df2e3c4d6ff4d2ee0d8b0b3 @jrbasso jrbasso committed with predominant Dec 13, 2009
Showing with 6 additions and 1 deletion.
  1. +4 −1 libs/br_validation.php
  2. +2 −0 tests/cases/libs/br_validation.test.php
View
5 libs/br_validation.php
@@ -56,7 +56,10 @@ function postal($check) {
* @access public
*/
function ssn($check) {
- $check = preg_replace('/[^0-9]/', '', $check);
+ $check = str_replace(array(' ', '-', '.', '/'), '', $check);
+ if (!ctype_digit($check)) {
+ return false;
+ }
return BrValidation::cpf($check) || BrValidation::cnjp($check);
}
View
2 tests/cases/libs/br_validation.test.php
@@ -107,6 +107,8 @@ function testSsn() {
// Testing invalid input
$this->assertFalse(BrValidation::ssn('3712093712890371289073901287390812'));
$this->assertFalse(BrValidation::ssn('33aaaa86000129'));
+ $this->assertFalse(BrValidation::ssn('22692173813xxx'));
+ $this->assertFalse(BrValidation::ssn('226921xxx73813'));
}
}
?>

0 comments on commit 7d7376a

Please sign in to comment.
Something went wrong with that request. Please try again.