blob: 5227c40ef9784619af91771909df64dfdca421a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
import inspect
from cerberus import Validator, DocumentError
def validate(schema, data):
v = Validator(schema)
if not v.validate(data):
frame = inspect.currentframe().f_back
caller_name = frame.f_code.co_name
raise DocumentError(f'{caller_name}: failed to validate data: ' + v.errors)
|