-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support minimum/maximum on quoted numerals #171
Comments
Side note, current schemaNode.isLong() || schemaNode.isInt() && JsonType.INTEGER.toString().equals(getNodeFieldType()) assuming it is a typo bug 🐜 and ( schemaNode.isLong() || schemaNode.isInt() ) && (JsonType.INTEGER.toString().equals(getNodeFieldType())) note the parentheses around |
@kosty You are right. The reason that we support the string format of integer type is due to the OpenAPI specification headers and query/path parameters. It is not part of the schema validation but since the library is tightly integrated into the light-4j framework, we need to give users an option to support the OpenAPI 3.0 specification for the data type validation. When we implementing that, we didn't even think about the maximum and minimum validators at all. Based on your suggestion, I think we need to implement both maximum and minimum and potentially other validators related to integers. Regarding the bug, I think one of them is not correct. @BalloonWen @jiachen1120, could you please take a look at the min/max validators? Thanks a lot for pointing out the issue. |
Bigger concern, actually, is that jackson's Oftentimes |
@kosty Thanks for point it out. I just debugged into it and found that textNode will be convert to |
@jiachen1120 Thanks for a quick turnaround! I have done some work on this as well, and should have a PR for you to look at. |
@kosty Thanks!! |
fixes #171 validation of quoted numerics added
Context
As mentioned in #118 there is a "loose" mode support for numeric types. Although not part of the JSON spec, the likely reason for such mode is JavaScript's specification of number type which basically uses only 64bit double type, aka 64-bit format IEEE 754-2008. Motivated by issues resulting from this well known behavior some languages converged on using serialized/quoted form when serializing long, double and bigger values to JSON, for example protocol buffers
Since quoted numeric values are accepted with loose typing other JSON Schema validators should handle them as well.
This issue focuses on
maximum
andminimum
validators at the moment.Sample test
A json payload like this
"9223372036854775807"
should check out agains schema like these
case 1
case 2
case 3
case 4
Essentially either of
integer
/number
types and any valid JSON number asmaximum
/minimum
value (including quoted numeric type).Edge case
Not clear if the following combination should trigger a
maximum
/minimum
validatorsjson
"42"
schema
The text was updated successfully, but these errors were encountered: