#Validate a field as positive integer only

1 messages · Page 1 of 1 (latest)

blissful burrow
#

Is it possible to create a field in a model that is a positive integer (or float) and have it automatically validated? E.g. using Pydantic's PositiveInt type? I've tried it and it doesn't seem to change the generated API spec.

queen current
#

mhm. This should be supported. Can you share some code that you've got and that's not working as expected?

#

Also, the validation should be handled by Pydantic, even if the schema doesn't reflect it; For Pydantic models, Litestar hands off the validation to Pydantic internally 🙂

blissful burrow
#

Ah maybe I should just try it and see

#

I assumed if it's not in the API spec then it's not working