Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from harikt/issue-55
Add tests and fix issue #55 .
- Loading branch information
Showing
9 changed files
with
249 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
namespace Aura\Input\Example; | ||
|
||
use Aura\Input\Filter; | ||
|
||
class ContactFilter extends Filter | ||
{ | ||
protected function init() | ||
{ | ||
$this->setRule( | ||
'first_name', | ||
'First name must be alphabetic only.', | ||
function ($value) { | ||
return ctype_alpha($value); | ||
} | ||
); | ||
|
||
$this->setRule( | ||
'last_name', | ||
'Last name must be alphabetic only.', | ||
function ($value) { | ||
return ctype_alpha($value); | ||
} | ||
); | ||
|
||
$this->setRule( | ||
'email', | ||
'Email not valid.', | ||
function ($value) { | ||
return filter_var($value, FILTER_VALIDATE_EMAIL); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,5 @@ public function testAll() | |
'value' => '234-567-8901', | ||
]; | ||
$this->assertSame($expect, $actual); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
namespace Aura\Input\Example; | ||
|
||
use Aura\Input\Filter; | ||
|
||
class PhoneFilter extends Filter | ||
{ | ||
protected function init() | ||
{ | ||
$this->setRule( | ||
'type', | ||
'Type is not valid.', | ||
function ($value) { | ||
$phoneTypes = [ | ||
'mobile', | ||
'home', | ||
'fax' | ||
]; | ||
return in_array($value, $phoneTypes); | ||
} | ||
); | ||
|
||
$this->setRule( | ||
'number', | ||
'Not a valid phone number.', | ||
function ($value) { | ||
return preg_match('/^[0-9-]+$/', $value); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters