Skip to content
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Agora, para utilizar a validação, basta fazer o procedimento padrão do `Larav

A diferença é que será possível usar os seguintes métodos de validação:



| REGRA | Descrição |
|:-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Celular | Valida se o campo está no formato (**`99999-9999`** ou **`9999-9999`**) |
Expand Down
4 changes: 2 additions & 2 deletions src/pt-br-validator/Rules/CelularComDdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Contracts\Validation\Rule;

/**
* @author Wallace Maxters <wallacemaxters@gmail.com>
* @author Samuel Lujan <samuel_lujan@hotmail.com>
*/
class CelularComDdd implements Rule
{
Expand All @@ -18,7 +18,7 @@ class CelularComDdd implements Rule
*/
public function passes($attribute, $value)
{
return preg_match('/^\(\d{2}\)\s?\d{4,5}-\d{4}$/', $value) > 0;
return preg_match('/^\(\d{2}\)\s?\d{4,5}-?\s?\d{4}$/', $value) > 0;
}

public function message()
Expand Down
4 changes: 2 additions & 2 deletions src/pt-br-validator/Rules/TelefoneComDdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Contracts\Validation\Rule;

/**
* @author Wallace Maxters <wallacemaxters@gmail.com>
* @author Samuel Lujan <samuel_lujan@hotmail.com>
*/
class TelefoneComDdd implements Rule
{
Expand All @@ -20,7 +20,7 @@ class TelefoneComDdd implements Rule

public function passes($attribute, $value)
{
return preg_match('/^\(\d{2}\)\s?\d{4}-\d{4}$/', $value) > 0;
return preg_match('/^\(\d{2}\)\s?\d{4}-?\s?\d{4}$/', $value) > 0;
}


Expand Down
5 changes: 0 additions & 5 deletions tests/TestRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function testCelularComDdd()
$this->assertTrue($validator->passes());
}


public function testCelularComCodigo()
{
$validator = \Validator::make([
Expand Down Expand Up @@ -66,10 +65,6 @@ public function testTelefoneComDdd()
$this->assertTrue($validator->passes());
}





public function testTelefoneComCodigo()
{
$validator = \Validator::make([
Expand Down