Skip to content

Commit e17370e

Browse files
committed
Update provider_options default arg value
1 parent 650cf9b commit e17370e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

aws_lambda_powertools/utilities/validation/base.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def validate_data_against_schema(
1313
schema: Dict,
1414
formats: Optional[Dict] = None,
1515
handlers: Optional[Dict] = None,
16-
**provider_options: Any,
16+
provider_options: Optional[Dict] = None,
1717
):
1818
"""Validate dict data against given JSON Schema
1919
@@ -27,7 +27,7 @@ def validate_data_against_schema(
2727
Custom formats containing a key (e.g. int64) and a value expressed as regex or callback returning bool
2828
handlers: Dict
2929
Custom methods to retrieve remote schemes, keyed off of URI scheme
30-
**provider options: Dict, optional
30+
provider_options: Dict
3131
Arguments that will be passed directly to the underlying validate call
3232
3333
Raises
@@ -40,6 +40,7 @@ def validate_data_against_schema(
4040
try:
4141
formats = formats or {}
4242
handlers = handlers or {}
43+
provider_options = provider_options or {}
4344
fastjsonschema.validate(definition=schema, data=data, formats=formats, handlers=handlers, **provider_options)
4445
except (TypeError, AttributeError, fastjsonschema.JsonSchemaDefinitionException) as e:
4546
raise InvalidSchemaFormatError(f"Schema received: {schema}, Formats: {formats}. Error: {e}")

aws_lambda_powertools/utilities/validation/validator.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def validator(
1717
inbound_schema: Optional[Dict] = None,
1818
inbound_formats: Optional[Dict] = None,
1919
inbound_handlers: Optional[Dict] = None,
20-
inbound_provider_options: Dict = {},
20+
inbound_provider_options: Optional[Dict] = None,
2121
outbound_schema: Optional[Dict] = None,
2222
outbound_formats: Optional[Dict] = None,
2323
outbound_handlers: Optional[Dict] = None,
24-
outbound_provider_options: Dict = {},
24+
outbound_provider_options: Optional[Dict] = None,
2525
envelope: str = "",
2626
jmespath_options: Optional[Dict] = None,
2727
**kwargs: Any,
@@ -144,7 +144,7 @@ def handler(event, context):
144144
schema=inbound_schema,
145145
formats=inbound_formats,
146146
handlers=inbound_handlers,
147-
**inbound_provider_options,
147+
provider_options=inbound_provider_options,
148148
)
149149

150150
response = handler(event, context, **kwargs)
@@ -156,7 +156,7 @@ def handler(event, context):
156156
schema=outbound_schema,
157157
formats=outbound_formats,
158158
handlers=outbound_handlers,
159-
**outbound_provider_options,
159+
provider_options=outbound_provider_options,
160160
)
161161

162162
return response
@@ -167,7 +167,7 @@ def validate(
167167
schema: Dict,
168168
formats: Optional[Dict] = None,
169169
handlers: Optional[Dict] = None,
170-
provider_options: Dict = {},
170+
provider_options: Optional[Dict] = None,
171171
envelope: Optional[str] = None,
172172
jmespath_options: Optional[Dict] = None,
173173
):
@@ -259,4 +259,6 @@ def handler(event, context):
259259
jmespath_options=jmespath_options,
260260
)
261261

262-
validate_data_against_schema(data=event, schema=schema, formats=formats, handlers=handlers, **provider_options)
262+
validate_data_against_schema(
263+
data=event, schema=schema, formats=formats, handlers=handlers, provider_options=provider_options
264+
)

0 commit comments

Comments
 (0)