Skip to content

Commit 833bf27

Browse files
committed
fixed README. Improved test coverage
1 parent d1eeada commit 833bf27

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ use LVR\Phone\NANP;
3535
use LVR\Phone\Digits;
3636

3737
// Test any phone number
38-
$request->validate(['test' => '15556667777'], new Phone); // Pass!
39-
$request->validate(['test' => '+15556667777'], new Phone); // Pass!
40-
$request->validate(['test' => '+1 (555) 666-7777'], new Phone); // Pass!
38+
$request->validate(['test' => '15556667777'], ['test' => new Phone]); // Pass!
39+
$request->validate(['test' => '+15556667777'], ['test' => new Phone]); // Pass!
40+
$request->validate(['test' => '+1 (555) 666-7777'], ['test' => new Phone]); // Pass!
4141

4242
// Test for E164
4343
$request->validate(['test' => '+15556667777'], ['test' => new E164]); // Pass!

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
},
2828
"minimum-stability": "stable",
2929
"require": {
30-
"illuminate/validation": "^5.5",
31-
"illuminate/support": "^5.5",
30+
"illuminate/contracts": "^5.5",
3231
"php": "^7.0"
3332
},
3433
"require-dev": {

tests/ValidatorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ public function testValidatorPhoneNANP()
7575

7676
public function testValidatorErrorMessage()
7777
{
78+
$validator = Validator::make(['attr' => '+1555 ex 1234'], ['attr' => new Phone]);
79+
$this->assertEquals("Incorrect phone format for attr.", $validator->errors()->first());
80+
7881
$validator = Validator::make(['attr' => '+1555 ex 1234'], ['attr' => new E164]);
7982
$this->assertEquals("attr must be in E.164 phone format", $validator->errors()->first());
83+
84+
$validator = Validator::make(['attr' => '+1555 ex 1234'], ['attr' => new NANP]);
85+
$this->assertEquals("attr must be in the NANP phone format", $validator->errors()->first());
86+
87+
$validator = Validator::make(['attr' => '+1555 ex 1234'], ['attr' => new Digits]);
88+
$this->assertEquals("attr must be in digits only phone format", $validator->errors()->first());
8089
}
8190
}

0 commit comments

Comments
 (0)