Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit381b428

Browse files
authored
Merge pull request#154 from geekcom/revert-151-master
Revert "fix CPF validation"
2 parents7d0040c +2d7e7ba commit381b428

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

‎src/validator-docs/Rules/Cpf.php‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,13 @@
44

55
namespacegeekcom\ValidatorDocs\Rules;
66

7-
usegeekcom\ValidatorDocs\ValidatorFormats;
8-
97
usefunctionpreg_match;
108
usefunctionmb_strlen;
119

1210
finalclass Cpfextends Sanitization
1311
{
14-
protectedfunctionvalidateCPFFormat(string$value)
15-
{
16-
if (!empty($value)) {
17-
return (newValidatorFormats())->execute($value,'cpf');
18-
}
19-
}
20-
2112
publicfunctionvalidateCpf($attribute,$value):bool
2213
{
23-
24-
if (!$this->validateCPFFormat($value)) {
25-
returnfalse;
26-
}
27-
2814
$c =$this->sanitize($value);
2915

3016
if (mb_strlen($c) !=11 ||preg_match("/^{$c[0]}{11}$/",$c)) {

‎src/validator-docs/Validator.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,19 @@ public function __construct(
3030
parent::__construct($translator,$data,$rules,$messages,$customAttributes);
3131
}
3232

33+
protectedfunctionvalidateFormat($value,$document,$attribute =null)
34+
{
35+
if (!empty($value)) {
36+
return (newValidatorFormats())->execute($value,$document);
37+
}
38+
}
39+
3340
protectedfunctionvalidateCpf($attribute,$value):bool
3441
{
3542
$cpf =newCpf();
3643

44+
$this->validateFormat($value,'cpf');
45+
3746
return$cpf->validateCpf($attribute,$value);
3847
}
3948

‎tests/TestValidator.php‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@ public function cpf()
1919
['errado' =>'cpf']
2020
);
2121

22-
$incorrectWithAlpha = Validator::make(
23-
['errado' =>'094.050.986-59ABCDEF'],
24-
['errado' =>'cpf']
25-
);
26-
2722
$this->assertTrue($correct->passes());
2823

2924
$this->assertTrue($incorrect->fails());
30-
31-
$this->assertTrue($incorrectWithAlpha->fails());
3225
}
3326

3427
/** @test **/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp