Thank you for reading!
You are suggesting custom validators, I was talking about the default validators provided by pydantic. These work fine, but image having a project with 50+ dataclasses, writing validators for each of the variables isn't really efficient.
You can see Springboot's validators. A simple message inside the annotation itself, simple and efficient.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
@fuadrafid
Actually to pass validation error message you can just use pydantic
@validator
decorator. For example:Then on validation error this will be the response body:
Thank you for reading!
You are suggesting custom validators, I was talking about the default validators provided by pydantic. These work fine, but image having a project with 50+ dataclasses, writing validators for each of the variables isn't really efficient.
You can see Springboot's validators. A simple message inside the annotation itself, simple and efficient.