Fixed small issues for ships endpoint validation
This commit is contained in:
parent
3d2e1f5158
commit
83520a2bc7
@ -45,7 +45,7 @@ def PostShip():
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("bad format"), 400
|
return json.dumps(repr(ex)), 400
|
||||||
|
|
||||||
return impl.ships.PostShip(loadedModel)
|
return impl.ships.PostShip(loadedModel)
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ def PutShip():
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("bad format"), 400
|
return json.dumps(repr(ex)), 400
|
||||||
|
|
||||||
return impl.ships.PutShip(loadedModel)
|
return impl.ships.PutShip(loadedModel)
|
||||||
|
|
||||||
@ -93,6 +93,6 @@ def DeleteShip():
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logging.error(ex)
|
logging.error(ex)
|
||||||
print(ex)
|
print(ex)
|
||||||
return json.dumps("bad format"), 400
|
return json.dumps(repr(ex)), 400
|
||||||
|
|
||||||
return impl.ships.DeleteShip(options)
|
return impl.ships.DeleteShip(options)
|
||||||
|
|||||||
@ -11,10 +11,10 @@ def check_if_string_has_special_characters(text:str):
|
|||||||
User: https://stackoverflow.com/users/10035985/andrej-kesely
|
User: https://stackoverflow.com/users/10035985/andrej-kesely
|
||||||
returns bool
|
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):
|
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
|
# 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())])
|
max_int = sum([int(val) for val in list(enum_object._value2member_map_.values())])
|
||||||
return 0 < value <= max_int
|
return 0 < value <= max_int
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user