Skip to content

Commit f99d58f

Browse files
committed
Remove deprecated methods from Validation class.
1 parent 0ca3550 commit f99d58f

File tree

2 files changed

+0
-194
lines changed

2 files changed

+0
-194
lines changed

src/Validation/Validation.php

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -654,91 +654,6 @@ public static function naturalNumber($check, $allowZero = false)
654654
return static::_check($check, $regex);
655655
}
656656

657-
/**
658-
* Checks that a value is a valid phone number.
659-
*
660-
* @param string|array $check Value to check (string or array)
661-
* @param string|null $regex Regular expression to use
662-
* @param string $country Country code (defaults to 'all')
663-
* @return bool Success
664-
* @deprecated 3.0.0 Will be removed in 3.0.0. Please use the Localized plugin instead.
665-
*/
666-
public static function phone($check, $regex = null, $country = 'all')
667-
{
668-
if (is_array($check)) {
669-
extract(static::_defaults($check));
670-
}
671-
672-
if ($regex === null) {
673-
switch ($country) {
674-
case 'us':
675-
case 'ca':
676-
case 'all':
677-
// includes all NANPA members.
678-
// see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
679-
$regex = '/^(?:(?:\+?1\s*(?:[.-]\s*)?)?';
680-
681-
// Area code 555, X11 is not allowed.
682-
$areaCode = '(?![2-9]11)(?!555)([2-9][0-8][0-9])';
683-
$regex .= '(?:\(\s*' . $areaCode . '\s*\)|' . $areaCode . ')';
684-
$regex .= '\s*(?:[.-]\s*)?)';
685-
686-
// Exchange and 555-XXXX numbers
687-
$regex .= '(?!(555(?:\s*(?:[.\-\s]\s*))(01([0-9][0-9])|1212)))';
688-
$regex .= '(?!(555(01([0-9][0-9])|1212)))';
689-
$regex .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)';
690-
691-
// Local number and extension
692-
$regex .= '?([0-9]{4})';
693-
$regex .= '(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/';
694-
break;
695-
}
696-
}
697-
698-
return static::_check($check, $regex);
699-
}
700-
701-
/**
702-
* Checks that a given value is a valid postal code.
703-
*
704-
* @param string|array $check Value to check
705-
* @param string|null $regex Regular expression to use
706-
* @param string $country Country to use for formatting
707-
* @return bool Success
708-
* @deprecated 3.0.0 Will be removed in 3.0.0. Please use the Localized plugin instead.
709-
*/
710-
public static function postal($check, $regex = null, $country = 'us')
711-
{
712-
if (is_array($check)) {
713-
extract(static::_defaults($check));
714-
}
715-
716-
if ($regex === null) {
717-
switch ($country) {
718-
case 'uk':
719-
$regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
720-
break;
721-
case 'ca':
722-
$district = '[ABCEGHJKLMNPRSTVYX]';
723-
$letters = '[ABCEGHJKLMNPRSTVWXYZ]';
724-
$regex = "/\\A\\b{$district}[0-9]{$letters} [0-9]{$letters}[0-9]\\b\\z/i";
725-
break;
726-
case 'it':
727-
case 'de':
728-
$regex = '/^[0-9]{5}$/i';
729-
break;
730-
case 'be':
731-
$regex = '/^[1-9]{1}[0-9]{3}$/i';
732-
break;
733-
case 'us':
734-
$regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
735-
break;
736-
}
737-
}
738-
739-
return static::_check($check, $regex);
740-
}
741-
742657
/**
743658
* Validates that a number is in specified range.
744659
*

tests/TestCase/Validation/ValidationTest.php

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,115 +2206,6 @@ public function testNaturalNumber()
22062206
$this->assertTrue(Validation::naturalNumber(0, true));
22072207
}
22082208

2209-
/**
2210-
* testPhone method
2211-
*
2212-
* @return void
2213-
*/
2214-
public function testPhone()
2215-
{
2216-
$this->assertFalse(Validation::phone('teststring'));
2217-
$this->assertFalse(Validation::phone('1-(33)-(333)-(4444)'));
2218-
$this->assertFalse(Validation::phone('1-(33)-3333-4444'));
2219-
$this->assertFalse(Validation::phone('1-(33)-33-4444'));
2220-
$this->assertFalse(Validation::phone('1-(33)-3-44444'));
2221-
$this->assertFalse(Validation::phone('1-(33)-3-444'));
2222-
$this->assertFalse(Validation::phone('1-(33)-3-44'));
2223-
2224-
$this->assertFalse(Validation::phone('(055) 999-9999'));
2225-
$this->assertFalse(Validation::phone('(155) 999-9999'));
2226-
$this->assertFalse(Validation::phone('(595) 999-9999'));
2227-
$this->assertFalse(Validation::phone('(213) 099-9999'));
2228-
$this->assertFalse(Validation::phone('(213) 199-9999'));
2229-
2230-
// invalid area-codes
2231-
$this->assertFalse(Validation::phone('1-(511)-999-9999'));
2232-
$this->assertFalse(Validation::phone('1-(555)-999-9999'));
2233-
2234-
// invalid exhange
2235-
$this->assertFalse(Validation::phone('1-(222)-511-9999'));
2236-
2237-
// invalid phone number
2238-
$this->assertFalse(Validation::phone('1-(222)-555-0199'));
2239-
$this->assertFalse(Validation::phone('1-(222)-555-0122'));
2240-
2241-
// valid phone numbers
2242-
$this->assertTrue(Validation::phone('416-428-1234'));
2243-
$this->assertTrue(Validation::phone('1-(369)-333-4444'));
2244-
$this->assertTrue(Validation::phone('1-(973)-333-4444'));
2245-
$this->assertTrue(Validation::phone('1-(313)-555-9999'));
2246-
$this->assertTrue(Validation::phone('1-(222)-555-0299'));
2247-
$this->assertTrue(Validation::phone('508-428-1234'));
2248-
$this->assertTrue(Validation::phone('1-(508)-232-9651'));
2249-
2250-
$this->assertTrue(Validation::phone('1 (222) 333 4444'));
2251-
$this->assertTrue(Validation::phone('+1 (222) 333 4444'));
2252-
$this->assertTrue(Validation::phone('(222) 333 4444'));
2253-
2254-
$this->assertTrue(Validation::phone('1-(333)-333-4444'));
2255-
$this->assertTrue(Validation::phone('1.(333)-333-4444'));
2256-
$this->assertTrue(Validation::phone('1.(333).333-4444'));
2257-
$this->assertTrue(Validation::phone('1.(333).333.4444'));
2258-
$this->assertTrue(Validation::phone('1-333-333-4444'));
2259-
}
2260-
2261-
/**
2262-
* testPostal method
2263-
*
2264-
* @return void
2265-
*/
2266-
public function testPostal()
2267-
{
2268-
$this->assertFalse(Validation::postal('111', null, 'de'));
2269-
$this->assertFalse(Validation::postal('1111', null, 'de'));
2270-
$this->assertTrue(Validation::postal('13089', null, 'de'));
2271-
2272-
$this->assertFalse(Validation::postal('111', null, 'be'));
2273-
$this->assertFalse(Validation::postal('0123', null, 'be'));
2274-
$this->assertTrue(Validation::postal('1204', null, 'be'));
2275-
2276-
$this->assertFalse(Validation::postal('111', null, 'it'));
2277-
$this->assertFalse(Validation::postal('1111', null, 'it'));
2278-
$this->assertTrue(Validation::postal('13089', null, 'it'));
2279-
2280-
$this->assertFalse(Validation::postal('111', null, 'uk'));
2281-
$this->assertFalse(Validation::postal('1111', null, 'uk'));
2282-
$this->assertFalse(Validation::postal('AZA 0AB', null, 'uk'));
2283-
$this->assertFalse(Validation::postal('X0A 0ABC', null, 'uk'));
2284-
$this->assertTrue(Validation::postal('X0A 0AB', null, 'uk'));
2285-
$this->assertTrue(Validation::postal('AZ0A 0AA', null, 'uk'));
2286-
$this->assertTrue(Validation::postal('A89 2DD', null, 'uk'));
2287-
2288-
$this->assertFalse(Validation::postal('111', null, 'ca'));
2289-
$this->assertFalse(Validation::postal('1111', null, 'ca'));
2290-
$this->assertFalse(Validation::postal('D2A 0A0', null, 'ca'));
2291-
$this->assertFalse(Validation::postal('BAA 0ABC', null, 'ca'));
2292-
$this->assertFalse(Validation::postal('B2A AABC', null, 'ca'));
2293-
$this->assertFalse(Validation::postal('B2A 2AB', null, 'ca'));
2294-
$this->assertFalse(Validation::postal('K1A 1D1', null, 'ca'));
2295-
$this->assertFalse(Validation::postal('K1O 1Q1', null, 'ca'));
2296-
$this->assertFalse(Validation::postal('A1A 1U1', null, 'ca'));
2297-
$this->assertFalse(Validation::postal('A1F 1B1', null, 'ca'));
2298-
$this->assertTrue(Validation::postal('X0A 0A2', null, 'ca'));
2299-
$this->assertTrue(Validation::postal('G4V 4C3', null, 'ca'));
2300-
2301-
$this->assertFalse(Validation::postal('111', null, 'us'));
2302-
$this->assertFalse(Validation::postal('1111', null, 'us'));
2303-
$this->assertFalse(Validation::postal('130896', null, 'us'));
2304-
$this->assertFalse(Validation::postal('13089-33333', null, 'us'));
2305-
$this->assertFalse(Validation::postal('13089-333', null, 'us'));
2306-
$this->assertFalse(Validation::postal('13A89-4333', null, 'us'));
2307-
$this->assertTrue(Validation::postal('13089-3333', null, 'us'));
2308-
2309-
$this->assertFalse(Validation::postal('111'));
2310-
$this->assertFalse(Validation::postal('1111'));
2311-
$this->assertFalse(Validation::postal('130896'));
2312-
$this->assertFalse(Validation::postal('13089-33333'));
2313-
$this->assertFalse(Validation::postal('13089-333'));
2314-
$this->assertFalse(Validation::postal('13A89-4333'));
2315-
$this->assertTrue(Validation::postal('13089-3333'));
2316-
}
2317-
23182209
/**
23192210
* testUserDefined method
23202211
*

0 commit comments

Comments
 (0)