Skip to content

Commit a20b2d2

Browse files
authored
fix: check national id length before checking its characters
1 parent 237ff13 commit a20b2d2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Rules/IranianNationalId.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Closure;
66
use Illuminate\Contracts\Validation\ValidationRule;
7+
use Illuminate\Support\Str;
78
use Sadegh19b\LaravelPersianValidation\Support\Helper;
89

910
class IranianNationalId implements ValidationRule
@@ -73,6 +74,10 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
7374
*/
7475
protected function isValidNationalCode(string $value): bool
7576
{
77+
if (Str::length($value) !== 10) {
78+
return false;
79+
}
80+
7681
$sum = 0;
7782
$values = str_split($value);
7883

0 commit comments

Comments
 (0)