-
Notifications
You must be signed in to change notification settings - Fork 330
Closed
Description
It seems as though this json schema validator doesn't correctly handle float-like integer values.
See this example test case:
@Test
fun int1() = runTest {
val schema = """{
"title": "foo",
"type": "object",
"required": ["x"],
"properties": {
"x": {
"type": "integer"
}
}
}"""
val a = "{\"x\": 1}"
val b = "{\"x\": 1.0}"
val ra = validationSchema.validate(schema, a)
val rb = validationSchema.validate(schema, b)
println(ra)
// ValidateResult(messages=[], errors=[])
println(rb)
// ValidateResult(messages=[$.x: number found, integer expected], errors=[ValidationError(code=1029, type=null, path=$.x, arguments=[number, integer], message=Invalid value. Must be a integer)])
}
We have a slight wrapper around networknt but this uses com.networknt.schema.JsonSchema.Set<ValidationMessage> validate(JsonNode node)
under the hood.
As per the JSON schema spec, both of these test cases should return zero errors, see https://json-schema.org/understanding-json-schema/reference/numeric.html#id4.
The code above was run using com.networknt:json-schema-validator:1.0.73
.
jdesrosiers
Metadata
Metadata
Assignees
Labels
No labels