Module aws_lambda_powertools.utilities.validation.base

Functions

def validate_data_against_schema(data: Union[Dict, str], schema: Dict, formats: Optional[Dict] = None, handlers: Optional[Dict] = None, provider_options: Optional[Dict] = None) ‑> Union[Dict, str]

Validate dict data against given JSON Schema

Parameters

data : Dict
Data set to be validated
schema : Dict
JSON Schema to validate against
formats : Dict
Custom formats containing a key (e.g. int64) and a value expressed as regex or callback returning bool
handlers : Dict
Custom methods to retrieve remote schemes, keyed off of URI scheme
provider_options : Dict
Arguments that will be passed directly to the underlying validation call, in this case fastjsonchema.validate. For all supported arguments see: https://horejsek.github.io/python-fastjsonschema/#fastjsonschema.validate

Returns

Dict
The validated event. If the schema specifies a default value for fields that are omitted, those default values will be included in the response.

Raises

SchemaValidationError
When schema validation fails against data set
InvalidSchemaFormatError
When JSON schema provided is invalid