0

I'm building a FastAPI project with SQLModel, which uses Pydantic under the hood. I'm following the SQLModel style to create models. I have a base class and all other classes inherit from it, including the class that's tied to the database table. I've got validation methods on the model that's tied to the database class. My question is this; will the validation methods be called for the CREATE, PUT, and PATCH classes used in the API routes?

writes_on
  • 1,735
  • 2
  • 22
  • 35
  • You question is very vague. I would suggest creating a [minimal reproducible example](https://stackoverflow.com/help/mcve) and first _trying that yourself_ and if something behaves in a way that you did not expect or do not understand, post your MRE here and ask a more precise question. As it stands right now, what does "tied to" mean? Which class? What `PUT` and `PATCH` classes? If you are asking, whether or not validators are inherited, the answer is yes, but again, it would have been trivial to test that yourself. – Daniil Fajnberg Mar 01 '23 at 18:37

0 Answers0