Skip to content

Commit

Permalink
BUGFIX: Fix CPF digits rest check
Browse files Browse the repository at this point in the history
  • Loading branch information
wemersonrv committed May 29, 2019
1 parent 6b6ae18 commit 8f053a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ if($validator->fails()){


## Release History
* 0.6.1
* BUGFIX: Fix CPF digits check
* CHANGE: Fix digit calculation, force 0 when rest result is 10
* 0.6.0
* Macc Address
* ADD: Mac Address rule (`mac_address`)
Expand Down
3 changes: 2 additions & 1 deletion src/Rules/Cpf.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public function passes($attribute, $value)
for($i=0; $i<strlen($body); $i++){
$result += $body[$i] * (10+$pass-$i);
}
$body .= $result % 11 ? 11 - ($result % 11) : 0;
$rest = $result % 11 ? 11 - ($result % 11) : 0;
$body .= $rest === 10 ? 0 : $rest;
}
return $body === $value;
}
Expand Down

0 comments on commit 8f053a7

Please sign in to comment.