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
* Improve type validation of integrals
Instead of doing string comparison, use new jackson method to determine if a number is an integral.
The `javaSemantics` config option was added in PR #343 which partially addressed issue #334. In the notes for this PR:
> Once jackson-databind 2.12.0 is out, I'll replace my solution with a call to canConvertToExactIntegral
jackson-databind has been updated to 2.12.1 so this is available but the change has not yet been made.
PR #450 which addressed #446 missed this location which is used when calling `JsonSchemaFactory.getSchema`.
Issue #344 requested coercion of various types but the only type implemented in PR #379 was lossless narrowing, set with configuration option `losslessNarrowing`. I believe that setting is unnecessary now as this implementation of `javaSemantics` addresses the original issue, but left it for backwards compatibility. It also allows you to set `javaSemantics=false` and `losslessNarrowing=true` to achieve only this specific case rather than anything that `javaSemantics` is used for in the future. At this time, these properties do exactly the same thing.
- Change from string comparison to `canConvertToExactIntegral` for `javaSemantics` and `losslessNarrowing`
- Add missing documentation around `losslessNarrowing`
- Add more test cases around integrals
* Update changelog
Copy file name to clipboardExpand all lines: doc/config.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,3 +55,11 @@ When set to true, use Java-specific semantics rather than native JavaScript sema
55
55
For example, if the node type is `number` per JS semantics where the value can be losslesly interpreted as `java.lang.Long`, the validator would use `integer` as the node type instead of `number`. This is useful when schema type is `integer`, since validation would fail otherwise.
56
56
57
57
For more details, please refer to this [issue](https://github.com/networknt/json-schema-validator/issues/334).
58
+
59
+
* losslessNarrowing
60
+
61
+
When set to true, can interpret round doubles as integers.
62
+
63
+
Note that setting `javaSemantics = true` will achieve the same functionality at this time.
64
+
65
+
For more details, please refer to this [issue](https://github.com/networknt/json-schema-validator/issues/344).
0 commit comments