Skip to content

Commit

Permalink
Merge pull request #68 from renan-s-oliveira/celular_com_codigo_sem_m…
Browse files Browse the repository at this point in the history
…ascara

add celular com codigo sem mascara'
  • Loading branch information
wallacemaxters authored Jul 19, 2023
2 parents 250a023 + e270a92 commit f868367
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 deletions.
30 changes: 30 additions & 0 deletions src/pt-br-validator/Rules/CelularComCodigoSemMascara.php
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';
}
}
39 changes: 20 additions & 19 deletions src/pt-br-validator/ValidatorProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,26 @@ class ValidatorProvider extends ServiceProvider
public function boot()
{
$rules = [
'celular' => \LaravelLegends\PtBrValidator\Rules\Celular::class,
'celular_com_ddd' => \LaravelLegends\PtBrValidator\Rules\CelularComDdd::class,
'celular_com_codigo' => \LaravelLegends\PtBrValidator\Rules\CelularComCodigo::class,
'cnh' => \LaravelLegends\PtBrValidator\Rules\Cnh::class,
'cnpj' => \LaravelLegends\PtBrValidator\Rules\Cnpj::class,
'cns' => \LaravelLegends\PtBrValidator\Rules\Cns::class,
'cpf' => \LaravelLegends\PtBrValidator\Rules\Cpf::class,
'formato_cnpj' => \LaravelLegends\PtBrValidator\Rules\FormatoCnpj::class,
'formato_cpf' => \LaravelLegends\PtBrValidator\Rules\FormatoCpf::class,
'telefone' => \LaravelLegends\PtBrValidator\Rules\Telefone::class,
'telefone_com_ddd' => \LaravelLegends\PtBrValidator\Rules\TelefoneComDdd::class,
'telefone_com_codigo' => \LaravelLegends\PtBrValidator\Rules\TelefoneComCodigo::class,
'formato_cep' => \LaravelLegends\PtBrValidator\Rules\FormatoCep::class,
'formato_placa_de_veiculo' => \LaravelLegends\PtBrValidator\Rules\FormatoPlacaDeVeiculo::class,
'formato_pis' => \LaravelLegends\PtBrValidator\Rules\FormatoPis::class,
'pis' => \LaravelLegends\PtBrValidator\Rules\Pis::class,
'cpf_ou_cnpj' => \LaravelLegends\PtBrValidator\Rules\CpfOuCnpj::class,
'formato_cpf_ou_cnpj' => \LaravelLegends\PtBrValidator\Rules\FormatoCpfOuCnpj::class,
'uf' => \LaravelLegends\PtBrValidator\Rules\Uf::class,
'celular' => \LaravelLegends\PtBrValidator\Rules\Celular::class,
'celular_com_ddd' => \LaravelLegends\PtBrValidator\Rules\CelularComDdd::class,
'celular_com_codigo' => \LaravelLegends\PtBrValidator\Rules\CelularComCodigo::class,
'celular_com_codigo_sem_mascara' => \LaravelLegends\PtBrValidator\Rules\CelularComCodigoSemMascara::class,
'cnh' => \LaravelLegends\PtBrValidator\Rules\Cnh::class,
'cnpj' => \LaravelLegends\PtBrValidator\Rules\Cnpj::class,
'cns' => \LaravelLegends\PtBrValidator\Rules\Cns::class,
'cpf' => \LaravelLegends\PtBrValidator\Rules\Cpf::class,
'formato_cnpj' => \LaravelLegends\PtBrValidator\Rules\FormatoCnpj::class,
'formato_cpf' => \LaravelLegends\PtBrValidator\Rules\FormatoCpf::class,
'telefone' => \LaravelLegends\PtBrValidator\Rules\Telefone::class,
'telefone_com_ddd' => \LaravelLegends\PtBrValidator\Rules\TelefoneComDdd::class,
'telefone_com_codigo' => \LaravelLegends\PtBrValidator\Rules\TelefoneComCodigo::class,
'formato_cep' => \LaravelLegends\PtBrValidator\Rules\FormatoCep::class,
'formato_placa_de_veiculo' => \LaravelLegends\PtBrValidator\Rules\FormatoPlacaDeVeiculo::class,
'formato_pis' => \LaravelLegends\PtBrValidator\Rules\FormatoPis::class,
'pis' => \LaravelLegends\PtBrValidator\Rules\Pis::class,
'cpf_ou_cnpj' => \LaravelLegends\PtBrValidator\Rules\CpfOuCnpj::class,
'formato_cpf_ou_cnpj' => \LaravelLegends\PtBrValidator\Rules\FormatoCpfOuCnpj::class,
'uf' => \LaravelLegends\PtBrValidator\Rules\Uf::class,
];

foreach ($rules as $name => $class) {
Expand Down

0 comments on commit f868367

Please sign in to comment.