schemas: remove raise_err kwarg

This commit is contained in:
Luna 2020-03-14 17:00:39 -03:00
parent 8dc27ae9de
commit 2fd86ec1d1
1 changed files with 4 additions and 11 deletions

View File

@ -162,21 +162,18 @@ class LitecordValidator(Validator):
return isinstance(value, str) and (len(value) < 32)
def validate(
reqjson: Optional[Union[Dict, List]], schema: Dict, raise_err: bool = True
) -> Dict:
def validate(reqjson: Optional[Union[Dict, List]], schema: Dict,) -> Dict:
"""Validate the given user-given data against a schema, giving the
"correct" version of the document, with all defaults applied.
Raises BadRequest error when the validation fails.
Parameters
----------
reqjson:
The input data
schema:
The schema to validate reqjson against
raise_err:
If we should raise a BadRequest error when the validation
fails. Default is true.
"""
validator = LitecordValidator(schema)
@ -192,11 +189,7 @@ def validate(
if not valid:
errs = validator.errors
log.warning("Error validating doc {!r}: {!r}", reqjson, errs)
if raise_err:
raise BadRequest("bad payload", errs)
return None
raise BadRequest("bad payload", errs)
return validator.document