diff options
author | Andrejs Verza <andrejs.verza@zabbix.com> | 2021-02-25 10:52:09 +0300 |
---|---|---|
committer | Andrejs Verza <andrejs.verza@zabbix.com> | 2021-02-25 10:52:09 +0300 |
commit | 0aa96caf5d9736b82b82ac0d30e430189da604d3 (patch) | |
tree | a8be5de88b886fec6344c3e41a4fe10ed2be8b3b | |
parent | e4f3887b12af4af85502ed23e88add08815d072b (diff) |
A......... [ZBXNEXT-6309] implemented length option for API_OBJECTS validation rule
-rw-r--r-- | ui/include/classes/validators/CApiInputValidator.php | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ui/include/classes/validators/CApiInputValidator.php b/ui/include/classes/validators/CApiInputValidator.php index 689bb7add89..d613d7e64e1 100644 --- a/ui/include/classes/validators/CApiInputValidator.php +++ b/ui/include/classes/validators/CApiInputValidator.php @@ -1134,6 +1134,7 @@ class CApiInputValidator { * @param array $rule * @param int $rule['flags'] (optional) API_NOT_EMPTY, API_ALLOW_NULL, API_NORMALIZE, API_PRESERVE_KEYS * @param array $rule['fields'] + * @param int $rule['length'] (optional) * @param mixed $data * @param string $path * @param string $error @@ -1157,6 +1158,11 @@ class CApiInputValidator { return false; } + if (array_key_exists('length', $rule) && count($data) > $rule['length']) { + $error = _s('Invalid parameter "%1$s": %2$s.', $path, _('value is too long')); + return false; + } + if (($flags & API_NORMALIZE) && $data) { reset($data); |