-
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.
Merge branch 'master' of https://github.com/LaravelLegends/pt-br-vali…
- Loading branch information
Showing
3 changed files
with
67 additions
and
22 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
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