Best way to implement reusable Custom Field Types? #555
-
I'm attempting to add some Custom Field Types like Still in the early stages of this, but was planning on implementing these field types as a standalone library so they can be used in projects that don't use aws-lambda-powertools-python (i.e. fastapi) and came across this in the Parser FAQ section of the docs: Based on the above, is using things like Pydantic's builtin classes like If so, would I need to define the import statement need to be different depending on if the library was being used in a powertools lambda function or not? Was also looking at Constrained Types like Netflix ConsoleMe but still not sure if there would be probs with the somewhat related Pydantic GH Issue: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hey @deric4 somehow we missed this due to GitHub Discussions feature. In your case, it's best to use What we're doing in Lambda Powertools is making sure you have an escape hatch should you need something from |
Beta Was this translation helpful? Give feedback.
hey @deric4 somehow we missed this due to GitHub Discussions feature. In your case, it's best to use
import pydantic
, because of this lineso they can be used in projects that don't use aws-lambda-powertools-python
.What we're doing in Lambda Powertools is making sure you have an escape hatch should you need something from
pydantic
that we don't expose directly. Because you have to installpydantic
to use the Parser utility, this will be available in the import namespace, so you can usefrom pydantic import ....
, orimport pydantic
as you normally would.