strictTypes
does not expect "narrowing" integer
with number keywords
#1935
Labels
Milestone
strictTypes
does not expect "narrowing" integer
with number keywords
#1935
What version of Ajv are you using? Does the issue happen if you use the latest version?
8.10.0
With all included schemas (default, 2019, 2020)
Ajv options object
JSON Schema
In english:
A number that must be an integer <= 5, or any number >= 10.
Sample data
Resolves as follows if
strictTypes
is'log'
orfalse
Your code
Validation result, data AFTER validation, error messages
What results did you expect?
No error message.
Documentation of
strictTypes
maximum
is a valid keyword forinteger
type, which is a "narrowing" ofnumber
.Note that the
else
does not error on missingtype: 'number'
and the error goes away iftype: 'integer'
is removed (as type is properly inferred from parent schema). Error also goes away ifmaximum: 5
is removed.Dropping
type: 'integer'
ormaximum: 5
, would logically alter schema, as above examples of 4.5 and 7 would then be valid.Are you going to resolve the issue?
Current local solution for me is to drop
strictTypes
(which does not impact validation, but is an overall appreciated feature).I'd be open to taking a swing at resolving, but would probably need some serious guidance on where to even start.
The text was updated successfully, but these errors were encountered: