From 0cb8d2244b08c72de0f5bc6d3a2681bd79d6ac51 Mon Sep 17 00:00:00 2001 From: Sadegh Date: Thu, 19 Sep 2019 02:12:48 +0430 Subject: [PATCH] change postal code validate pattern --- src/PersianValidators.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PersianValidators.php b/src/PersianValidators.php index d03fb69..4be58b8 100644 --- a/src/PersianValidators.php +++ b/src/PersianValidators.php @@ -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 @@ -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); } /**