P5-4418 validate Pwinty SKU code

This commit is contained in:
Martin
2019-11-11 08:11:14 +01:00
parent 95a264af99
commit 9efb59fb9f
6 changed files with 86 additions and 12 deletions
+19
View File
@@ -94,3 +94,22 @@ def validate_territory(*keys):
return wrapper
return decorator
def validate_any_of(key, values):
def decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
_check_parameter_exists(key)
value = request.args.get(key)
if not value in values:
raise ValidationError(
"{} contains an invalid value, must be one of: {}".format(
key, values
)
)
return f(*args, **kwargs)
return wrapper
return decorator