From 10372861c950ea97450ce7261d33d7da100a9d4c Mon Sep 17 00:00:00 2001 From: Daniel Kerr Date: Sat, 10 Feb 2024 05:53:00 +0800 Subject: [PATCH] new validations functions --- upload/admin/controller/catalog/attribute.php | 2 +- upload/admin/controller/catalog/attribute_group.php | 2 +- upload/admin/controller/catalog/category.php | 4 ++-- upload/admin/controller/catalog/download.php | 2 +- upload/admin/controller/catalog/product.php | 2 +- upload/admin/controller/catalog/subscription_plan.php | 2 +- upload/admin/controller/cms/antispam.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/upload/admin/controller/catalog/attribute.php b/upload/admin/controller/catalog/attribute.php index e63faaf8ebc..0e0f991fb53 100644 --- a/upload/admin/controller/catalog/attribute.php +++ b/upload/admin/controller/catalog/attribute.php @@ -276,7 +276,7 @@ public function save(): void { } foreach ($this->request->post['attribute_description'] as $language_id => $value) { - if ((oc_strlen(trim($value['name'])) < 1) || (oc_strlen($value['name']) > 64)) { + if (!oc_validate_length($value['name'], 1, 64)) { $json['error']['name_' . $language_id] = $this->language->get('error_name'); } } diff --git a/upload/admin/controller/catalog/attribute_group.php b/upload/admin/controller/catalog/attribute_group.php index f0326f1d582..c7e445f67d5 100644 --- a/upload/admin/controller/catalog/attribute_group.php +++ b/upload/admin/controller/catalog/attribute_group.php @@ -260,7 +260,7 @@ public function save(): void { } foreach ($this->request->post['attribute_group_description'] as $language_id => $value) { - if ((oc_strlen(trim($value['name'])) < 1) || (oc_strlen($value['name']) > 64)) { + if (!oc_validate_length($value['name'], 1, 64)) { $json['error']['name_' . $language_id] = $this->language->get('error_name'); } } diff --git a/upload/admin/controller/catalog/category.php b/upload/admin/controller/catalog/category.php index 0be29403413..91388fe970f 100644 --- a/upload/admin/controller/catalog/category.php +++ b/upload/admin/controller/catalog/category.php @@ -386,11 +386,11 @@ public function save(): void { } foreach ($this->request->post['category_description'] as $language_id => $value) { - if ((oc_strlen(trim($value['name'])) < 1) || (oc_strlen($value['name']) > 255)) { + if (!oc_validate_length($value['name'], 1, 255)) { $json['error']['name_' . $language_id] = $this->language->get('error_name'); } - if ((oc_strlen(trim($value['meta_title'])) < 1) || (oc_strlen($value['meta_title']) > 255)) { + if (!oc_validate_length($value['meta_title'], 1, 255)) { $json['error']['meta_title_' . $language_id] = $this->language->get('error_meta_title'); } } diff --git a/upload/admin/controller/catalog/download.php b/upload/admin/controller/catalog/download.php index 9fdbb98ffba..69021949fa4 100644 --- a/upload/admin/controller/catalog/download.php +++ b/upload/admin/controller/catalog/download.php @@ -274,7 +274,7 @@ public function save(): void { } foreach ($this->request->post['download_description'] as $language_id => $value) { - if ((oc_strlen(trim($value['name'])) < 3) || (oc_strlen($value['name']) > 64)) { + if (!oc_validate_length($value['name'], 3, 64)) { $json['error']['name_' . $language_id] = $this->language->get('error_name'); } } diff --git a/upload/admin/controller/catalog/product.php b/upload/admin/controller/catalog/product.php index f9ad54a0b8a..d2fc2226ab9 100644 --- a/upload/admin/controller/catalog/product.php +++ b/upload/admin/controller/catalog/product.php @@ -1070,7 +1070,7 @@ public function save(): void { } foreach ($this->request->post['product_description'] as $language_id => $value) { - if ((oc_strlen(trim($value['name'])) < 1) || (oc_strlen($value['name']) > 255)) { + if (!oc_validate_length($value['name'], 1, 255)) { $json['error']['name_' . $language_id] = $this->language->get('error_name'); } diff --git a/upload/admin/controller/catalog/subscription_plan.php b/upload/admin/controller/catalog/subscription_plan.php index 3363f8d55f5..d7e51da6037 100644 --- a/upload/admin/controller/catalog/subscription_plan.php +++ b/upload/admin/controller/catalog/subscription_plan.php @@ -337,7 +337,7 @@ public function save(): void { } foreach ($this->request->post['subscription_plan_description'] as $language_id => $value) { - if ((oc_strlen(trim($value['name'])) < 3) || (oc_strlen($value['name']) > 255)) { + if (!oc_validate_length($value['name'], 3, 255)) { $json['error']['name_' . $language_id] = $this->language->get('error_name'); } } diff --git a/upload/admin/controller/cms/antispam.php b/upload/admin/controller/cms/antispam.php index 6776b3aa399..09c643b46f2 100644 --- a/upload/admin/controller/cms/antispam.php +++ b/upload/admin/controller/cms/antispam.php @@ -276,7 +276,7 @@ public function save(): void { $json['error']['warning'] = $this->language->get('error_permission'); } - if ((oc_strlen($this->request->post['keyword']) < 1) || (oc_strlen($this->request->post['keyword']) > 64)) { + if (!oc_validate_length($this->request->post['keyword'], 1, 64)) { $json['error']['keyword'] = $this->language->get('error_keyword'); }