Browse Source

Removing Validation::personId

as discussed at https://github.com/cakephp/cakephp/pull/4116#issuecomment-51052188
Marc Würth 11 years ago
parent
commit
22a1f8adbb
2 changed files with 2 additions and 67 deletions
  1. 0 33
      src/Validation/Validation.php
  2. 2 34
      tests/TestCase/Validation/ValidationTest.php

+ 0 - 33
src/Validation/Validation.php

@@ -740,39 +740,6 @@ class Validation {
 	}
 
 /**
- * Checks that a value is a valid identification number.
- * In the case of US this would be the Social Security Number (SSN).
- *
- * @param string|array $check Value to check
- * @param string $regex Regular expression to use
- * @param string $country Country
- * @return bool Success
- */
-	public static function personId($check, $regex = null, $country = null) {
-		if (is_array($check)) {
-			extract(static::_defaults($check));
-		}
-
-		if ($regex === null) {
-			switch ($country) {
-				case 'dk':
-					$regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
-					break;
-				case 'nl':
-					$regex = '/\\A\\b[0-9]{9}\\b\\z/i';
-					break;
-				case 'us':
-					$regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
-					break;
-			}
-		}
-		if (empty($regex)) {
-			return static::_pass('personId', $check, $country);
-		}
-		return static::_check($check, $regex);
-	}
-
-/**
  * Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
  *
  * The regex checks for the following component parts:

+ 2 - 34
tests/TestCase/Validation/ValidationTest.php

@@ -57,16 +57,6 @@ class TestNlValidation {
 		return true;
 	}
 
-/**
- * personId function for testing identification pass through.
- *
- * @param string $check
- * @return void
- */
-	public static function personId($check) {
-		return true;
-	}
-
 }
 
 /**
@@ -2286,14 +2276,13 @@ class ValidationTest extends TestCase {
 	}
 
 /**
- * test that phone, postal and personId pass to other classes.
+ * Test that phone and postal pass to other classes.
  *
  * @return void
  */
-	public function testPhonePostalPhonePersonIdPass() {
+	public function testPostalPhonePass() {
 		$this->assertTrue(Validation::postal('text', null, __NAMESPACE__ . '\TestNlValidation'));
 		$this->assertTrue(Validation::phone('text', null, __NAMESPACE__ . '\TestDeValidation'));
-		$this->assertTrue(Validation::personId('text', null, __NAMESPACE__ . '\TestNlValidation'));
 	}
 
 /**
@@ -2326,27 +2315,6 @@ class ValidationTest extends TestCase {
 	}
 
 /**
- * testPersonId method
- *
- * @return void
- */
-	public function testPersonId() {
-		$this->assertFalse(Validation::personId('111-333', null, 'dk'));
-		$this->assertFalse(Validation::personId('111111-333', null, 'dk'));
-		$this->assertTrue(Validation::personId('111111-3334', null, 'dk'));
-
-		$this->assertFalse(Validation::personId('1118333', null, 'nl'));
-		$this->assertFalse(Validation::personId('1234567890', null, 'nl'));
-		$this->assertFalse(Validation::personId('12345A789', null, 'nl'));
-		$this->assertTrue(Validation::personId('123456789', null, 'nl'));
-
-		$this->assertFalse(Validation::personId('11-33-4333', null, 'us'));
-		$this->assertFalse(Validation::personId('113-3-4333', null, 'us'));
-		$this->assertFalse(Validation::personId('111-33-333', null, 'us'));
-		$this->assertTrue(Validation::personId('111-33-4333', null, 'us'));
-	}
-
-/**
  * testUserDefined method
  *
  * @return void