Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '7.4', '8.0', '8.1']
php-version: ['7.2', '7.4', '8.1']
prefer-lowest: ['']
include:
- php-version: '7.2'
Expand Down Expand Up @@ -49,14 +49,14 @@ jobs:
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
elif ${{ matrix.php-version == '8.1' }}; then
composer update --ignore-platform-reqs
composer update --ignore-platform-reqs
else
composer update
fi

- name: Configure PHPUnit matcher
if: matrix.php-version == '7.4'
uses: mheap/phpunit-matcher-action@master
uses: mheap/phpunit-matcher-action@main

- name: Run PHPUnit
run: |
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/UsValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function phone(string $check): bool
$pattern .= '|([2-9][0-9]{2}))\s*(?:[.-]\s*)?)';
$pattern .= '(?!(555(?:\s*(?:[.|\-|\s]\s*))(01([0-9][0-9])|1212)))';
$pattern .= '(?!(555(01([0-9][0-9])|1212)))';
$pattern .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)';
$pattern .= '([2-9]1[01-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)';
$pattern .= '?([0-9]{4})';
$pattern .= '(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/';

Expand Down
7 changes: 5 additions & 2 deletions tests/TestCase/Validation/UsValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function testPhone()
$this->assertFalse(UsValidation::phone('1-(123)-999-9999'));
$this->assertFalse(UsValidation::phone('1-(555)-999-9999'));

// invalid exchange
$this->assertFalse(UsValidation::phone('1-(222)-511-9999'));
// invalid exchange (can't start with 1)
$this->assertFalse(UsValidation::phone('1-(222)-125-9999'));

// invalid phone number
$this->assertFalse(UsValidation::phone('1-(222)-555-0199'));
Expand Down Expand Up @@ -83,6 +83,9 @@ public function testPhone()
$this->assertTrue(UsValidation::phone('805 773 0789'));
$this->assertTrue(UsValidation::phone('1-(570)-773-0789'));
$this->assertTrue(UsValidation::phone('1-(573)-773-0789'));

$this->assertTrue(UsValidation::phone('1-(573)-811-0789'));
$this->assertTrue(UsValidation::phone('1-(222)-511-9999'));
}

/**
Expand Down