Skip to content

Commit

Permalink
arquivos de validação de sigla conforme a escolha do país
Browse files Browse the repository at this point in the history
  • Loading branch information
paulomartinhago committed Jan 26, 2014
1 parent d2ca4b5 commit eeccbc0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/Respect/Validation/Country/Brasil.php
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;
}
}
6 changes: 6 additions & 0 deletions library/Respect/Validation/Country/ICountry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
namespace Respect\Validation\Country;

interface ICountry {
public function getUF();
}
18 changes: 18 additions & 0 deletions library/Respect/Validation/Rules/UF.php
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());
}
}

0 comments on commit eeccbc0

Please sign in to comment.