Add validation logic to use the "format" parameter
Closed this issue · 4 comments
Format is an additional parameter that can be added to string and numbe types: https://swagger.io/specification/?sbsearch=format. Some of the values that can be given to format could be used to run additional validation. For example:
type: string
format: date-time
This could be validated using datetime.
type: number
format: float
This could be validated as being a float or integer, etc.
So it looks to me like this would be the full list of formats to consider:
date-time
: validate as ISO 8601 datetimedate
: dittobyte
binary
, which can be a series of octets?10011101.11100010.10101110.11101000
And the password
one is interesting. Do we hide the output from error messages for a password type?
There isn't anything to consider for signed 32 bit int vs 64 bit in python is there?
there is also the float format as mentioned in the OP.
for 32 and 64 bit signed ints we do not need to do anything i think.
So a double
is a float with exactly 2 decimals, but what is a float
in this case? Any precision except 2 decimals?
its a good question TBH, there are various edge cases here: https://stackoverflow.com/questions/736043/checking-if-a-string-can-be-converted-to-float-in-python