Skip to content

Commit

Permalink
Merge pull request #3 from hossein-zare/master
Browse files Browse the repository at this point in the history
Fix illegal chars in sheba.
  • Loading branch information
sadegh19b authored Dec 23, 2021
2 parents 6e9022e + 085b86f commit 293b0ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/PersianValidators.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,14 @@ public function validateIranianBankSheba($attribute, $value, $parameters)
{
$ibanReplaceValues = array();

if (!empty($value))
if (! empty($value))
{
$value = preg_replace('/[\W_]+/', '', strtoupper($value));
$_value = preg_replace('/[\W_]+/', '', strtoupper($value));

if (( 4 > strlen($value) || strlen($value) > 34 ) || ( is_numeric($value [ 0 ]) || is_numeric($value [ 1 ]) ) || ( ! is_numeric($value [ 2 ]) || ! is_numeric($value [ 3 ]) )) {
if ($_value !== strtoupper($value))
return false;

if (( 4 > strlen($_value) || strlen($_value) > 34 ) || ( is_numeric($_value [ 0 ]) || is_numeric($_value [ 1 ]) ) || ( ! is_numeric($_value [ 2 ]) || ! is_numeric($_value [ 3 ]) )) {
return false;
}

Expand All @@ -329,7 +332,7 @@ public function validateIranianBankSheba($attribute, $value, $parameters)
$ibanReplaceValues[] = strval($tempvalue);
}

$tmpIBAN = substr($value, 4) . substr($value, 0, 4);
$tmpIBAN = substr($_value, 4) . substr($_value, 0, 4);
$tmpIBAN = str_replace($ibanReplaceChars, $ibanReplaceValues, $tmpIBAN);
$tmpValue = intval(substr($tmpIBAN, 0, 1));

Expand Down

0 comments on commit 293b0ca

Please sign in to comment.