From 83520a2bc728ccab4ecfcc9388ee8c7ea2577b4d Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 9 Jul 2024 09:04:05 +0200 Subject: [PATCH] Fixed small issues for ships endpoint validation --- src/server/BreCal/api/ships.py | 6 +++--- src/server/BreCal/validators/validation_base_utils.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index 96bceb2..d968476 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -45,7 +45,7 @@ def PostShip(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return json.dumps(repr(ex)), 400 return impl.ships.PostShip(loadedModel) @@ -67,7 +67,7 @@ def PutShip(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return json.dumps(repr(ex)), 400 return impl.ships.PutShip(loadedModel) @@ -93,6 +93,6 @@ def DeleteShip(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return json.dumps(repr(ex)), 400 return impl.ships.DeleteShip(options) diff --git a/src/server/BreCal/validators/validation_base_utils.py b/src/server/BreCal/validators/validation_base_utils.py index 82ced1f..1e44d17 100644 --- a/src/server/BreCal/validators/validation_base_utils.py +++ b/src/server/BreCal/validators/validation_base_utils.py @@ -11,10 +11,10 @@ def check_if_string_has_special_characters(text:str): User: https://stackoverflow.com/users/10035985/andrej-kesely returns bool """ - return bool(set(text).difference(ascii_letters + digits)) + return bool(set(text).difference(ascii_letters + digits + ' ')) def check_if_int_is_valid_flag(value, enum_object): # e.g., when an IntFlag has the values 1,2,4; the maximum valid value is 7 max_int = sum([int(val) for val in list(enum_object._value2member_map_.values())]) - return 0 < value <= max_int \ No newline at end of file + return 0 < value <= max_int