1
In the Laravel
, both the 4 and the 5, we have the class Validator
, which allows specific validations to be made.
By default there are several, such as required
, email
, same
and others.
But I would also like to be able to validate a phone number with ddd.
Example:
$valores = ['telefone' => '(31)9995-5088'];
$rules = ['telefone' => 'required|minha_validacao_de_telefone']
Validator::make($valores, $regras);
How could I add a phone validation on Laravel
?
Is there any way to add a regular expression in the validation of Laravel
?
^\(\d{2}\) ?\d{4,5}-\d{4}$
:D– Guilherme Lautert
Thanks, Marnolo!
– Wallace Maxters