Skip to content

Commit 81948ee

Browse files
author
Oliver Friesen
committed
Issue: 246
1 parent 06d58d4 commit 81948ee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

aws_lambda_powertools/utilities/validation/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
logger = logging.getLogger(__name__)
1212

1313

14-
def validate_data_against_schema(data: Dict, schema: Dict):
14+
def validate_data_against_schema(data: Dict, schema: Dict, formats: Dict):
1515
"""Validate dict data against given JSON Schema
1616
1717
Parameters
@@ -29,7 +29,7 @@ def validate_data_against_schema(data: Dict, schema: Dict):
2929
When JSON schema provided is invalid
3030
"""
3131
try:
32-
fastjsonschema.validate(definition=schema, data=data)
32+
fastjsonschema.validate(definition=schema, data=data, formats=formats)
3333
except fastjsonschema.JsonSchemaException as e:
3434
message = f"Failed schema validation. Error: {e.message}, Path: {e.path}, Data: {e.value}" # noqa: B306, E501
3535
raise SchemaValidationError(message)

aws_lambda_powertools/utilities/validation/validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def handler(event, context):
125125
return response
126126

127127

128-
def validate(event: Dict, schema: Dict = None, envelope: str = None, jmespath_options: Dict = None):
128+
def validate(event: Dict, schema: Dict = None, formats: Dict = {}, envelope: str = None, jmespath_options: Dict = None):
129129
"""Standalone function to validate event data using a JSON Schema
130130
131131
Typically used when you need more control over the validation process.
@@ -201,4 +201,4 @@ def handler(event, context):
201201
if envelope:
202202
event = unwrap_event_from_envelope(data=event, envelope=envelope, jmespath_options=jmespath_options)
203203

204-
validate_data_against_schema(data=event, schema=schema)
204+
validate_data_against_schema(data=event, schema=schema, formats=formats)

0 commit comments

Comments
 (0)