Skip to content

Commit 6e9022e

Browse files
committed
Fixed Some bug in validateIranianBankCardNumber and langs
1 parent 686cd69 commit 6e9022e

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lang/en/persian-validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'ir_phone_code' => 'The :attribute must be a iranian phone area code number.',
1414
'ir_phone_with_code' => 'The :attribute must be a iranian phone number with area code.',
1515
'ir_postal_code' => 'The :attribute must be a iranian postal code.',
16-
'ir_card_number' => 'The :attribute must be a valid iranian payment card number.',
16+
'ir_bank_card_number' => 'The :attribute must be a valid iranian payment card number.',
1717
'ir_sheba' => 'The :attribute must be a iranian sheba number.',
1818
'ir_national_code' => 'The :attribute must be a iranian national code.',
1919
'a_url' => 'The :attribute is an invalid url.',

lang/fa/persian-validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'ir_phone_code' => $incorrectMsg,
1717
'ir_phone_with_code' => ':attribute باید بهمراه کد استان وارد شود.',
1818
'ir_postal_code' => $invalidMsg,
19-
'ir_card_number' => $invalidMsg,
19+
'ir_bank_card_number' => $invalidMsg,
2020
'ir_sheba' => $invalidMsg,
2121
'ir_national_code' => $invalidMsg,
2222
'a_url' => $incorrectMsg,

src/PersianValidators.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,16 @@ public function validateIranianPostalCode($attribute, $value, $parameters)
273273
function validateIranianBankCardNumber($attribute, $value, $parameters)
274274
{
275275
if (isset($parameters[0]) && $parameters[0] == 'seprate') {
276+
if (!preg_match('/^\d{4}-\d{4}-\d{4}-\d{4}$/', $value)) {
277+
return false;
278+
}
276279
$value = str_replace('-', '', $value);
277280
}
278281

279282
if (isset($parameters[0]) && $parameters[0] == 'space') {
283+
if (!preg_match('/^\d{4}\s\d{4}\s\d{4}\s\d{4}$/', $value)) {
284+
return false;
285+
}
280286
$value = str_replace(' ', '', $value);
281287
}
282288

0 commit comments

Comments
 (0)