You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/utilities/validation.mdx
+34
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,40 @@ def handler(event, context):
69
69
return event
70
70
```
71
71
72
+
### Validating custom formats
73
+
74
+
> New in 1.10.0
75
+
> **NOTE**: JSON Schema DRAFT 7 [has many new built-in formats](https://json-schema.org/understanding-json-schema/reference/string.html#format) such as date, time, and specifically a regex format which might be a better replacement for a custom format, if you do have control over the schema.
76
+
77
+
If you have JSON Schemas with custom formats, for example having a `int64` for high precision integers, you can pass an optional validation to handle each type using `formats` parameter - Otherwise it'll fail validation:
78
+
79
+
**Example of custom integer format**
80
+
81
+
```json
82
+
{
83
+
"lastModifiedTime": {
84
+
"format": "int64",
85
+
"type": "integer"
86
+
}
87
+
}
88
+
```
89
+
90
+
For each format defined in a dictionary key, you must use a regex, or a function that returns a boolean to instruct the validator on how to proceed when encountering that type.
91
+
92
+
```python
93
+
from aws_lambda_powertools.utilities.validation import validate
94
+
95
+
event = {} # some event
96
+
schema_with_custom_format = {} # some JSON schema that defines a custom format
0 commit comments