fix(api): predefined value for float

This commit is contained in:
pycook 2023-12-29 10:57:34 +08:00
parent 7036fe023c
commit e37650f4fc
1 changed files with 7 additions and 2 deletions

View File

@ -94,6 +94,11 @@ class AttributeValueManager(object):
@staticmethod @staticmethod
def _check_is_choice(attr, value_type, value): def _check_is_choice(attr, value_type, value):
choice_values = AttributeManager.get_choice_values(attr.id, value_type, attr.choice_web_hook, attr.choice_other) choice_values = AttributeManager.get_choice_values(attr.id, value_type, attr.choice_web_hook, attr.choice_other)
if value_type == ValueTypeEnum.FLOAT:
if float(value) not in list(map(float, [i[0] for i in choice_values])):
return abort(400, ErrFormat.not_in_choice_values.format(value))
else:
if str(value) not in list(map(str, [i[0] for i in choice_values])): if str(value) not in list(map(str, [i[0] for i in choice_values])):
return abort(400, ErrFormat.not_in_choice_values.format(value)) return abort(400, ErrFormat.not_in_choice_values.format(value))