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
4. Parser then parsed the `detail` key using `UserModel`
290
292
291
293
292
-
### Built-in envelopes
294
+
### built-in envelopes
293
295
294
296
Parser comes with the following built-in envelopes, where `Model` in the return section is your given model.
295
297
@@ -300,8 +302,10 @@ Envelope name | Behaviour | Return
300
302
**SqsEnvelope** | 1. Parses data using `SqsModel`. <br/> 2. Parses records in `body` key using your model and return them in a list. | `List[Model]`
301
303
**CloudWatchLogsEnvelope** | 1. Parses data using `CloudwatchLogsModel` which will base64 decode and decompress it. <br/> 2. Parses records in `message` key using your model and return them in a list. | `List[Model]`
302
304
**KinesisDataStreamEnvelope** | 1. Parses data using `KinesisDataStreamModel` which will base64 decode it. <br/> 2. Parses records in in `Records` key using your model and returns them in a list. | `List[Model]`
305
+
**SnsEnvelope** | 1. Parses data using `SqsModel`. <br/> 2. Parses records in `body` key using your model and return them in a list. | `List[Model]`
306
+
**SnsSqsEnvelope** | 1. Parses data using `SqsModel`. <br/> 2. Parses SNS records in `body` key using `SnsNotificationModel`. <br/> 3. Parses data in `Message` key using your model and return them in a list. | `List[Model]`
303
307
304
-
### Bringing your own envelope
308
+
### bringing your own envelope
305
309
306
310
You can create your own Envelope model and logic by inheriting from `BaseEnvelope`, and implementing the `parse` method.
307
311
@@ -366,7 +370,7 @@ class EventBridgeEnvelope(BaseEnvelope): # highlight-line
366
370
3. Then, we parsed the incoming data with our envelope to confirm it matches EventBridge's structure defined in `EventBridgeModel`
367
371
4. Lastly, we call `_parse` from `BaseEnvelope` to parse the data in our envelope (.detail) using the customer model
368
372
369
-
###Data model validation
373
+
## Data model validation
370
374
371
375
<Notetype="warning">
372
376
This is radically different from the <strong>Validator utility</strong> which validates events against JSON Schema.
@@ -384,7 +388,7 @@ Keep the following in mind regardless of which decorator you end up using it:
384
388
* You must raise either `ValueError`, `TypeError`, or `AssertionError` when value is not compliant
385
389
* You must return the value(s) itself if compliant
386
390
387
-
#### Validating fields
391
+
###validating fields
388
392
389
393
Quick validation to verify whether the field `message` has the value of `hello world`.
390
394
@@ -429,7 +433,7 @@ class HelloWorldModel(BaseModel):
`root_validator` can help when you have a complex validation mechanism. For example finding whether data has been omitted, comparing field values, etc.
0 commit comments