-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbc431a
commit e270a92
Showing
2 changed files
with
50 additions
and
19 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,30 @@ | ||
<?php | ||
|
||
namespace LaravelLegends\PtBrValidator\Rules; | ||
|
||
use Illuminate\Contracts\Validation\Rule; | ||
|
||
/** | ||
* @author Wallace Maxters <[email protected]> | ||
*/ | ||
class CelularComCodigoSemMascara implements Rule | ||
{ | ||
|
||
|
||
/** | ||
* Valida o formato do celular com código do país | ||
* | ||
* @param string $attribute | ||
* @param string $value | ||
* @return boolean | ||
*/ | ||
public function passes($attribute, $value) | ||
{ | ||
return preg_match('/^[+]\d{1,2}\s?\d{2}\s?\d{4,5}\d{4}$/', $value) > 0; | ||
} | ||
|
||
public function message() | ||
{ | ||
return 'O campo :attribute não é um celular válido. Exemplo de celular válido +5514999999999'; | ||
} | ||
} |
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