validate expression of rule in API
parent
4a33acbbee
commit
1bee235c6d
|
@ -115,6 +115,11 @@ class RuleCollection:
|
||||||
title='API.BAD_REQUEST',
|
title='API.BAD_REQUEST',
|
||||||
description='API.INVALID_EXPRESSION')
|
description='API.INVALID_EXPRESSION')
|
||||||
expression = str.strip(new_values['data']['expression'])
|
expression = str.strip(new_values['data']['expression'])
|
||||||
|
# validate expression in json
|
||||||
|
try:
|
||||||
|
json.loads(expression)
|
||||||
|
except Exception as ex:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description=ex)
|
||||||
|
|
||||||
if 'message_template' not in new_values['data'].keys() or \
|
if 'message_template' not in new_values['data'].keys() or \
|
||||||
not isinstance(new_values['data']['message_template'], str) or \
|
not isinstance(new_values['data']['message_template'], str) or \
|
||||||
|
@ -305,6 +310,11 @@ class RuleItem:
|
||||||
title='API.BAD_REQUEST',
|
title='API.BAD_REQUEST',
|
||||||
description='API.INVALID_EXPRESSION')
|
description='API.INVALID_EXPRESSION')
|
||||||
expression = str.strip(new_values['data']['expression'])
|
expression = str.strip(new_values['data']['expression'])
|
||||||
|
# validate expression in json
|
||||||
|
try:
|
||||||
|
json.loads(expression)
|
||||||
|
except Exception as ex:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description=ex)
|
||||||
|
|
||||||
if 'message_template' not in new_values['data'].keys() or \
|
if 'message_template' not in new_values['data'].keys() or \
|
||||||
not isinstance(new_values['data']['message_template'], str) or \
|
not isinstance(new_values['data']['message_template'], str) or \
|
||||||
|
|
Loading…
Reference in New Issue