fromfunctoolsimportreducefromtypingimportAny,Callable,Dictfrom.importformatsfrom.error_reportingimportdetailed_errors,ValidationErrorfrom.extra_validationsimportEXTRA_VALIDATIONSfrom.fastjsonschema_exceptionsimportJsonSchemaException,JsonSchemaValueExceptionfrom.fastjsonschema_validationsimportvalidateas_validate__all__=["validate","FORMAT_FUNCTIONS","EXTRA_VALIDATIONS","ValidationError","JsonSchemaException","JsonSchemaValueException",]FORMAT_FUNCTIONS:Dict[str, Callable[[str], bool]]={fn.__name__.replace("_","-"):fnforfninformats.__dict__.values()ifcallable(fn)andnotfn.__name__.startswith("_")}defvalidate(data:Any)->bool:"""Validate the given ``data`` object using JSON Schema
This function raises ``ValidationError`` if ``data`` is invalid.
"""withdetailed_errors():_validate(data,custom_formats=FORMAT_FUNCTIONS)reduce(lambdaacc,fn:fn(acc),EXTRA_VALIDATIONS,data)returnTrue