forked from Respect/Validation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arquivos de validação de sigla conforme a escolha do país
- Loading branch information
1 parent
d2ca4b5
commit eeccbc0
Showing
3 changed files
with
34 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
namespace Respect\Validation\Country; | ||
|
||
class Brasil implements ICountry { | ||
private $uf = array('AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MT', 'MS', 'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN', 'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO'); | ||
|
||
public function getUF(){ | ||
return $this->uf; | ||
} | ||
} |
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,6 @@ | ||
<?php | ||
namespace Respect\Validation\Country; | ||
|
||
interface ICountry { | ||
public function getUF(); | ||
} |
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,18 @@ | ||
<?php | ||
namespace Respect\Validation\Rules; | ||
|
||
use Respect\Validation\Country\ICountry; | ||
|
||
class UF extends AbstractRule | ||
{ | ||
private $country; | ||
|
||
public function __construct(ICountry $country){ | ||
$this->country = $country; | ||
} | ||
|
||
public function validate($input) | ||
{ | ||
return in_array($input, $this->country->getUF()); | ||
} | ||
} |