From 9333dcc971fb3ef4cb220f3843fee200d0d9db66 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 5 May 2020 11:42:14 +0700 Subject: [PATCH] added check field != matches[1] of {(\w+)\} if found --- system/Validation/Rules.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index 1c318aea1e51..d9f7bece51f3 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -168,7 +168,8 @@ public function is_not_unique(string $str = null, string $field, array $data): b if (! empty($where_field) && ! empty($where_value)) { - if (! preg_match('/\{(\w+)\}/', $where_value)) + preg_match('/{(\w+)\}/', $where_value, $matches); + if (! $matches || $where_field !== $matches[1]) { $row = $row->where($where_field, $where_value); } @@ -231,7 +232,8 @@ public function is_unique(string $str = null, string $field, array $data): bool if (! empty($ignoreField) && ! empty($ignoreValue)) { - if (! preg_match('/\{(\w+)\}/', $ignoreValue)) + preg_match('/{(\w+)\}/', $ignoreValue, $matches); + if (! $matches || $ignoreField !== $matches[1]) { $row = $row->where("{$ignoreField} !=", $ignoreValue); }