Open curvedriver opened 2 years ago
It's been a conscious choice not to limit the range of floats, as the most common use case for validation is processing incoming data, and in this case data being out of range wouldn't prevent its processing in JS code.
I understand that it may be needed for cases when you validate data on its way to some consumer that would have such limits... e.g. database.
So, happy to add support for validating these ranges with some option. PR is welcome.
What version of Ajv are you using? Does the issue happen if you use the latest version? 8.11.0
Ajv options object
I'm using the default options.
JTD Schema
Sample data
Validation result, data AFTER validation, error messages
What results did you expect? The same behaviour as it is in case of integer data types. If a value is out of range of the defined data type, then the
ValidationFunction
should returnfalse
and an errors should be added to theerrors
list.Validation in case of the integer types: https://github.com/ajv-validator/ajv/blob/e73bc750634947f4270597136e203c27213aa565/lib/vocabularies/jtd/type.ts#L66
In case of
float32
andfloat64
is such a validation missing: https://github.com/ajv-validator/ajv/blob/e73bc750634947f4270597136e203c27213aa565/lib/vocabularies/jtd/type.ts#L58