Remix.run Logo
NeutralForest 4 days ago

I'm not sure I agree, you can still use Pydantic in the domain model and update the version of the API when you change the expected schemas of your CRUD application.

Where I'm with you, is that you should take care of your boundaries and muddling the line between your Pydantic domain models and your CRUD models will be painful at some point. If your domain model is changing fast compared to the API you're exposing, that could be an issue.

But that's not a "Pydantic in the domain layer" issue, that's a separation of concerns issue.

chausen 4 days ago | parent [-]

Often you want your domain models to be structured differently than API models, to make them as convenient/understandable to work with as possible for your use case. If you already have different models, why would you want Pydantic in the domain? Even if they start out the same, this would allow them to more easily evolve to be different. I'm not a python expert, so I could be missing the point on Pydantic, but it seems like its value is at the edges of your application.

NeutralForest 4 days ago | parent [-]

That's all fair, I just think it has more to do with separation of concerns than Pydantic and that the OP doesn't make it clear at all.