Skip to content
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

[BUG] jsonschema maximum 提示文案错误 #1854

Open
shpodg opened this issue Sep 12, 2023 · 1 comment
Open

[BUG] jsonschema maximum 提示文案错误 #1854

shpodg opened this issue Sep 12, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@shpodg
Copy link

shpodg commented Sep 12, 2023

问题描述

maximum not match, expect >= %s, but %s

环境信息

  • 版本信息:Fastjson2 2.0.40

重现步骤

final JSONSchema jsonSchema = JSONSchema.of(JSONObject.of("type", "integer", "maximum", 10));
jsonSchema.assertValidate(11);

期待的正确结果

maximum not match, expect <= 10, but 11

相关日志输出

com.alibaba.fastjson2.JSONSchemaValidException: maximum not match, expect >= 10, but 11
at com.alibaba.fastjson2.schema.JSONSchema.assertValidate(JSONSchema.java:814)

@shpodg shpodg added the bug Something isn't working label Sep 12, 2023
@GabrielHwang
Copy link
Contributor

问题似乎出现在这里

if (maximum != Long.MIN_VALUE) {
if (exclusiveMaximum ? longValue >= maximum : longValue > maximum) {
return new ValidateResult(false, exclusiveMaximum ? "exclusiveMaximum not match, expect >= %s, but %s" : "maximum not match, expect >= %s, but %s", maximum, longValue);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants