Skip to content

Commit

Permalink
change postal code validate pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
sadegh19b committed Sep 18, 2019
1 parent 9cc5868 commit 0cb8d22
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/PersianValidators.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public function validateIranianPhoneWithAreaCode($attribute, $value, $parameters

/**
* Validate Iran postal code format.
* Old pattern /^(\d{5}-?\d{5})$/
* New pattern ref: https://stackoverflow.com/questions/48719799/iranian-postal-code-validation
*
* @param $attribute
* @param $value
Expand All @@ -127,7 +129,7 @@ public function validateIranianPhoneWithAreaCode($attribute, $value, $parameters
*/
public function validateIranianPostalCode($attribute, $value, $parameters)
{
return preg_match("/^(\d{5}-?\d{5})$/", $value);
return preg_match("\b(?!(\d)\1{3})[13-9]{4}[1346-9]-?[013-9]{5}\b", $value);
}

/**
Expand Down

0 comments on commit 0cb8d22

Please sign in to comment.