Skip to content

Commit

Permalink
Fixed Some bug in validateIranianBankCardNumber and langs
Browse files Browse the repository at this point in the history
  • Loading branch information
sadegh19b committed Feb 8, 2021
1 parent 686cd69 commit 6e9022e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lang/en/persian-validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'ir_phone_code' => 'The :attribute must be a iranian phone area code number.',
'ir_phone_with_code' => 'The :attribute must be a iranian phone number with area code.',
'ir_postal_code' => 'The :attribute must be a iranian postal code.',
'ir_card_number' => 'The :attribute must be a valid iranian payment card number.',
'ir_bank_card_number' => 'The :attribute must be a valid iranian payment card number.',
'ir_sheba' => 'The :attribute must be a iranian sheba number.',
'ir_national_code' => 'The :attribute must be a iranian national code.',
'a_url' => 'The :attribute is an invalid url.',
Expand Down
2 changes: 1 addition & 1 deletion lang/fa/persian-validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'ir_phone_code' => $incorrectMsg,
'ir_phone_with_code' => ':attribute باید بهمراه کد استان وارد شود.',
'ir_postal_code' => $invalidMsg,
'ir_card_number' => $invalidMsg,
'ir_bank_card_number' => $invalidMsg,
'ir_sheba' => $invalidMsg,
'ir_national_code' => $invalidMsg,
'a_url' => $incorrectMsg,
Expand Down
6 changes: 6 additions & 0 deletions src/PersianValidators.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,16 @@ public function validateIranianPostalCode($attribute, $value, $parameters)
function validateIranianBankCardNumber($attribute, $value, $parameters)
{
if (isset($parameters[0]) && $parameters[0] == 'seprate') {
if (!preg_match('/^\d{4}-\d{4}-\d{4}-\d{4}$/', $value)) {
return false;
}
$value = str_replace('-', '', $value);
}

if (isset($parameters[0]) && $parameters[0] == 'space') {
if (!preg_match('/^\d{4}\s\d{4}\s\d{4}\s\d{4}$/', $value)) {
return false;
}
$value = str_replace(' ', '', $value);
}

Expand Down

0 comments on commit 6e9022e

Please sign in to comment.