-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathValidator.php
More file actions
132 lines (102 loc) · 3.2 KB
/
Validator.php
File metadata and controls
132 lines (102 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
namespace geekcom\ValidatorDocs;
use geekcom\ValidatorDocs\Rules\{Certidao,
Cnh,
Cnpj,
Cns,
Cpf,
Ddd,
InscricaoEstadual,
Nis,
Placa,
Renavam,
TituloEleitoral,
Passaporte};
use Illuminate\Contracts\Translation\Translator;
use Illuminate\Validation\Validator as BaseValidator;
class Validator extends BaseValidator
{
public function __construct(
Translator $translator,
ValidatorFormats $formatValidator,
array $data,
array $rules,
array $messages = [],
array $customAttributes = []
) {
parent::__construct($translator, $data, $rules, $messages, $customAttributes);
}
protected function validateFormat($value, $document, $attribute = null)
{
if (!empty($value)) {
return (new ValidatorFormats())->execute($value, $document);
}
}
protected function validateCpf($attribute, $value): bool
{
$cpf = new Cpf();
$this->validateFormat($value, 'cpf');
return $cpf->validateCpf($attribute, $value);
}
protected function validateCnpj($attribute, $value): bool
{
$cnpj = new Cnpj();
return $cnpj->validateCnpj($attribute, $value);
}
protected function validateCpfCnpj($attribute, $value): bool
{
$cpf = new Cpf();
$cnpj = new Cnpj();
return ($cpf->validateCpf($attribute, $value) || $cnpj->validateCnpj($attribute, $value));
}
protected function validateCnh($attribute, $value): bool
{
$cnh = new Cnh();
return $cnh->validateCnh($attribute, $value);
}
protected function validateTituloEleitor($attribute, $value): bool
{
$tituloEleitoral = new TituloEleitoral();
return $tituloEleitoral->validateTituloEleitor($attribute, $value);
}
protected function validateNis($attribute, $value): bool
{
$nis = new Nis();
return $nis->validateNis($attribute, $value);
}
protected function validateCns($attribute, $value): bool
{
$cns = new Cns();
return $cns->validateCns($attribute, $value);
}
protected function validateCertidao($attribute, $value): bool
{
$certidao = new Certidao();
return $certidao->validateCertidao($attribute, $value);
}
protected function validateInscricaoEstadual($attribute, $value, $parameters): bool
{
$inscricaoEstadual = new InscricaoEstadual();
return $inscricaoEstadual->validateInscricaoEstadual($attribute, $value, $parameters);
}
protected function validateRenavam($attribute, $value): bool
{
$renavam = new Renavam();
return $renavam->validateRenavam($attribute, $value);
}
protected function validatePlaca($attribute, $value): bool
{
$placa = new Placa();
return $placa->validatePlaca($attribute, $value);
}
protected function validateDdd($attribute, $value): bool
{
$ddd = new Ddd();
return $ddd->validateDdd($attribute, $value);
}
protected function validatePassaporte($attribute, $value): bool
{
$passaporte = new Passaporte();
return $passaporte->validatePassaporte($attribute, $value);
}
}