Closed hnkelau closed 3 years ago
Schema({'float': float}).validate({'float':1.0})
or
from schema import Use Schema({'float': Use(float)}).validate({'float':1})
Thanks for the suggested solutions!
from schema import Use Schema({'float': Use(float)}).validate({'float':1})
Will work wonders!
Hello!
I ran into a failed validation today and as far as I can tell float validation is not following JSON Schema convention when validating a float.
In [8]: Schema({'float':float}).validate({'float':1})
raises:
SchemaError: Key 'float' error: 1 should be instance of 'float
when it should pass the validation according to https://json-schema.org/understanding-json-schema/reference/numeric.html#number given the following correctly compiled schema:
It looks like the "double assert" at https://github.com/keleshev/schema/blob/master/test_schema.py#L249 is hiding this issue.