From f134865c1e61aa7b808dbe46c2d7d33eb34c5183 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 1 Jul 2024 11:32:59 +0700 Subject: update get params for boolean flash sale --- indoteknik_api/controllers/controller.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'indoteknik_api/controllers/controller.py') diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py index a5a05c1b..a34a2688 100644 --- a/indoteknik_api/controllers/controller.py +++ b/indoteknik_api/controllers/controller.py @@ -93,15 +93,10 @@ class Controller(http.Controller): value = '' if 'required' in rules and not value: result['reason'].append(f"{key} is required") - if 'number' in rules and value and not value.isdigit(): + if is_number and value and not value.isdigit(): result['reason'].append(f"{key} must be a number") - if is_boolean and value: - if value.lower() in ['true', '1']: - value = True - elif value.lower() in ['false', '0']: - value = False - else: - result['reason'].append(f"{key} must be a boolean") + if is_boolean and value and value.lower() not in ['true', 'false', '1', '0']: + result['reason'].append(f"{key} must be a boolean") result['query'][key] = value @@ -109,13 +104,8 @@ class Controller(http.Controller): value = default if is_number and value.isdigit(): value = int(value) - - # Assign the boolean value if is_boolean: - if value.lower() in ['true', '1']: - value = True - elif value.lower() in ['false', '0']: - value = False + value = value.lower() in ['true', '1'] if not value and is_exclude_if_null: continue -- cgit v1.2.3