You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently both MaximumValidator and MinimumValidator both rely on double as their base type. This causes some omissions for integer numbers, e.g. 9223372036854775807 and 9223372036854775806 are both rounded up to 9223372036854776000 which leads to bug in validation when former is the value validated and latter is the maximum threshold in schema. Corresponding issues is demonstrated by -9223372036854775808 and -9223372036854775807 for minimum.
Sample test
@Test
public void testIntegralMaximum() throws IOException {
ObjectMapper m = new ObjectMapper();
String schema = "{ \"$schema\":\"http://json-schema.org/draft-04/schema#\", \"type\": \"integer\", \"maximum\": 9223372036854775806 }";
JsonSchema v = JsonSchemaFactory.getInstance().getSchema(m.readTree(schema));
JsonNode doc = m.readTree("9223372036854775807");
Set<ValidationMessage> messages = v.validate(doc);
assertFalse(messages.isEmpty());
}
Notes
Since json-schema-validator is optimized for speed of validation, conditional statements inside validate method are not desirable. Similarly, comparison of primitive numeric types is preferred to BigInteger / BigDecimal.
The text was updated successfully, but these errors were encountered:
@stevehu@jiachen1120 Thanks a lot for the effort. I have released a new version 1.0.6 minutes ago and upgraded light-4j framework with the new version with light-bot.
Description
Currently both
MaximumValidator
andMinimumValidator
both rely ondouble
as their base type. This causes some omissions forinteger
numbers, e.g.9223372036854775807
and9223372036854775806
are both rounded up to9223372036854776000
which leads to bug in validation when former is the value validated and latter is themaximum
threshold in schema. Corresponding issues is demonstrated by-9223372036854775808
and-9223372036854775807
forminimum
.Sample test
Notes
Since
json-schema-validator
is optimized for speed of validation, conditional statements insidevalidate
method are not desirable. Similarly, comparison of primitive numeric types is preferred toBigInteger
/BigDecimal
.The text was updated successfully, but these errors were encountered: