From fda862928bc0414e9aa2d30a3a7b25a395fe0b7a Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 16 Sep 2023 02:01:48 +0300 Subject: [PATCH] fix keyword topic validation --- example/environment/env.example.php | 2 +- src/library/valid.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/example/environment/env.example.php b/example/environment/env.example.php index 2505cd0..229b24d 100644 --- a/example/environment/env.example.php +++ b/example/environment/env.example.php @@ -103,7 +103,7 @@ define('MAGNET_DN_MIN_LENGTH', 10); define('MAGNET_DN_MAX_LENGTH', 255); define('MAGNET_DN_REGEX', '/.*/ui'); -define('MAGNET_KT_MIN_LENGTH', 10); +define('MAGNET_KT_MIN_LENGTH', 2); define('MAGNET_KT_MAX_LENGTH', 140); define('MAGNET_KT_REGEX', '/[\w]+/ui'); define('MAGNET_KT_MIN_QUANTITY', 0); diff --git a/src/library/valid.php b/src/library/valid.php index 5f3bb48..4143606 100644 --- a/src/library/valid.php +++ b/src/library/valid.php @@ -637,7 +637,7 @@ class Valid foreach ($value as $kt) { - if (!is_string($value)) + if (!is_string($kt)) { array_push( $error, @@ -647,7 +647,7 @@ class Valid return false; } - if (!preg_match(MAGNET_KT_REGEX, $value)) + if (!preg_match(MAGNET_KT_REGEX, $kt)) { array_push( $error, @@ -660,8 +660,8 @@ class Valid return false; } - if (mb_strlen($value) < MAGNET_KT_MIN_LENGTH || - mb_strlen($value) > MAGNET_KT_MAX_LENGTH) + if (mb_strlen($kt) < MAGNET_KT_MIN_LENGTH || + mb_strlen($kt) > MAGNET_KT_MAX_LENGTH) { array_push( $error,