flask-parameter-validation icon indicating copy to clipboard operation
flask-parameter-validation copied to clipboard

Question: How to validate the min and max value of a float

Open DavidCBerry13 opened this issue 1 year ago • 3 comments

I see there are parameters for min_int and max_int and expected to see similar parameters for floats, but didn't see any. Did I miss something? Is there another way to do this? It would seem like min_float and max_float would be nice additions for when dealing with floats.

DavidCBerry13 avatar Dec 07 '24 21:12 DavidCBerry13

Hi! Good question - at least currently, you're able to do that using the func parameter - that said, adding float mins and maxes shouldn't be a big lift

smt5541 avatar Dec 07 '24 21:12 smt5541

Thanks @smt5541 . You confirmed what I was thinking that the way to tackle this today would be to use a func parameter.

I took a look at the code as well and agree it shouldn't be too big of an effort to add in min_float and max_float--would probably pretty much replicate how min_int and max_int are implemented. If I get adventurous over the holidays I'll try to conjure up a PR.

DavidCBerry13 avatar Dec 07 '24 22:12 DavidCBerry13

It would probably be good here to replace min/max min_int/max_int with just a generic "min" and "max", that will automatically change depending on input type.

Ge0rg3 avatar Dec 09 '24 14:12 Ge0rg3