diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-01 11:32:59 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-01 11:32:59 +0700 |
| commit | f134865c1e61aa7b808dbe46c2d7d33eb34c5183 (patch) | |
| tree | 88b7a32216b4a9a2967dc580d6c841d73b7f0354 /indoteknik_api/controllers/controller.py | |
| parent | a54492e34db2a43d9aae2d575b2b3c073669631c (diff) | |
<iman> update get params for boolean flash sale
Diffstat (limited to 'indoteknik_api/controllers/controller.py')
| -rw-r--r-- | indoteknik_api/controllers/controller.py | 18 |
1 files changed, 4 insertions, 14 deletions
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 |
