Skip to content

Commit d2148f2

Browse files
committed
docs: add a FAQ section
Signed-off-by: heitorlessa <lessa@amazon.co.uk>
1 parent 5f1ad0a commit d2148f2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/content/utilities/parser.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,21 @@ class EventBridgeEnvelope(BaseEnvelope): # highlight-line
438438
2. Implemented the `parse` abstract method taking `data` and `model` as parameters
439439
3. Then, we parsed the incoming data with our envelope to confirm it matches EventBridge's structure defined in `EventBridgeModel`
440440
4. Lastly, we call `_parse` from `BaseEnvelope` to parse the data in our envelope (.detail) using the customer model
441+
442+
## FAQ
443+
444+
**When should I use parser vs data_classes utility?**
445+
446+
Use data classes utility when you're after autocomplete, self-documented attributes and helpers to extract data from common event sources.
447+
448+
Parser is best suited for those looking for a trade-off between defining their models for deep validation, parsing and autocomplete for an additional dependency to be brought in.
449+
450+
**How do I import X from Pydantic?**
451+
452+
We export most common classes, exceptions, and utilities from Pydantic as part of parser e.g. `from aws_lambda_powertools.utilities.parser import BaseModel`.
453+
454+
If what's your trying to use isn't available as part of the high level import system, use the following escape hatch mechanism:
455+
456+
```python:title=escape_hatch.py
457+
from aws_lambda_powertools.utilities.parser.pydantic import <what you'd like to import'>
458+
```

0 commit comments

Comments
 (0)