Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
ValidationError: 19.99 is not a multiple of 0.01
Expected Behavior
Validation shall pass. Note: values 9.99
, 29.99
are passing. It's only 19.99 has an issue.
JSON schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "multipleOf round error reproducer",
"required": ["price"],
"type": "object",
"properties": {
"price": {
"description": "Product price",
"type": "number",
"minimum": 0,
"multipleOf": 0.01
}
}
}
Library version
0.0.8
Anything else?
Full reproducer
val jsonStr = """
{
"price": 19.99
}
""".trimIndent()
val schema = """
{
"${"$"}schema": "http://json-schema.org/draft-07/schema#",
"description": "multipleOf round error reproducer",
"required": ["price"],
"type": "object",
"properties": {
"price": {
"description": "Product price",
"type": "number",
"minimum": 0,
"multipleOf": 0.01
}
}
}
""".trimIndent()
val jsonSchema = JsonSchema.fromDefinition(schema)
val jsonElement = Json.parseToJsonElement(jsonStr)
val errors = mutableListOf<ValidationError>()
jsonSchema.validate(jsonElement, errors::add)
assertThat(errors).isEmpty()
Metadata
Metadata
Assignees
Labels
Projects
Status
✅ Done