-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
Description
Issue Summary
The JTD validator is incorrectly accepting decimal values like 3.14 for int32 type schemas, when it should reject them according to RFC 8927.
Expected Behavior
- int32 type schema should reject non-integer decimal values like 3.14
- Validation should fail with appropriate error message
- This applies to all integer types: int8, uint8, int16, uint16, int32, uint32
Actual Behavior
- int32 type schema is incorrectly accepting 3.14 as valid
- No validation errors are reported
- This violates RFC 8927 integer type specification
Test Case
JsonValue schema = Json.parse('{"type": "int32"}');
JsonValue decimalValue = JsonNumber.of(new BigDecimal("3.14"));
Jtd.Result result = new Jtd().validate(schema, decimalValue);
// result.isValid() returns true (incorrect)
Root Cause
Looking at JtdSchema.java lines 243-245, there is logic to check for non-integral values but it only handles Double instances. When creating JsonNumber with BigDecimal("3.14"), the value may not be a Double, so the check is bypassed.
Fix Required
The integer validation logic needs to properly handle all numeric types including BigDecimal and check if they have fractional parts.
Acceptance Criteria
- int32 rejects 3.14 (BigDecimal)
- int32 rejects 3.14 (Double)
- All integer types reject decimal values
- Appropriate error messages are returned
- Existing valid integer tests still pass