Should I use Pydantic models in the core logic of my backend? /u/fedetask Python Education

I am writing the backend of a web application and I will use Fastapi with Pydantic for the API. However, I was asking myself if it would be a good practice to use the Pydantic objects directly in the core logic of the backend.

I reached this point because I might want to use the core logic layer for other purposes that do not require FastAPI (e.g. a desktop application) so even if I implement validation logic in the API layer, I would still need to re-implement it also in the core logic.

At this point, I might directly write the core logic using Pydantic models. Would that be a bad idea? If yes, why? I have never used Pydantic before, so I might be missing something

submitted by /u/fedetask
[link] [comments]

​r/learnpython I am writing the backend of a web application and I will use Fastapi with Pydantic for the API. However, I was asking myself if it would be a good practice to use the Pydantic objects directly in the core logic of the backend. I reached this point because I might want to use the core logic layer for other purposes that do not require FastAPI (e.g. a desktop application) so even if I implement validation logic in the API layer, I would still need to re-implement it also in the core logic. At this point, I might directly write the core logic using Pydantic models. Would that be a bad idea? If yes, why? I have never used Pydantic before, so I might be missing something submitted by /u/fedetask [link] [comments] 

I am writing the backend of a web application and I will use Fastapi with Pydantic for the API. However, I was asking myself if it would be a good practice to use the Pydantic objects directly in the core logic of the backend.

I reached this point because I might want to use the core logic layer for other purposes that do not require FastAPI (e.g. a desktop application) so even if I implement validation logic in the API layer, I would still need to re-implement it also in the core logic.

At this point, I might directly write the core logic using Pydantic models. Would that be a bad idea? If yes, why? I have never used Pydantic before, so I might be missing something

submitted by /u/fedetask
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *