-
Notifications
You must be signed in to change notification settings - Fork 330
Closed
Description
Issue
TypeFactory uses jackson-databind
's JsonNode.isIntegralNumber
and JsonNode.isNumber
to see if the node's type is integer or number, respectively. This result is used when comparing node type and schema type which is not precise enough in some cases.
if (node.isIntegralNumber()) | |
return JsonType.INTEGER; | |
if (node.isNumber()) | |
return JsonType.NUMBER; |
Scenario
Assume that we have a schema where a property's type is integer
.
Given a DecimalNode(v)
where v
is a value that can fit into Long
, json-schema-validator thinks that node type is number
and this results in type failure as number found, integer expected
Proposal
Update line 72-73 in the snippet above as following (canConvertToLong()
is defined for DecimalNode
at jackson-databind
)
if (node.isIntegralNumber() || node.canConvertToLong())
return JsonType.INTEGER;
so that we can have a validator with better precision
WeishiZ
Metadata
Metadata
Assignees
Labels
No labels