-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Clarify numerical validation errors #54
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
Conversation
Current messages for `minimum` and `maximum` were misleading for a wide audience. Messages are now changed to "at least" for `minimum` and "at most" for `maximum`. Code simplified.
lib/jsonschema.lua
Outdated
| ctx:stmt(sformat(' if %s %s %s then', ctx:param(1), op, schema.minimum)) | ||
| ctx:stmt(sformat(' return false, %s("expected %%s to be %s than %s", %s)', | ||
| ctx:libfunc('string.format'), msg, schema.minimum, ctx:param(1))) | ||
| local addRangeCheck = function (op, reference, msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way of writing has a bad performance. You can use this way:
local function(ctx, op, reference, msg)
... ...
end
generate_validator = function(ctx, schema)
...
if schema.minimum then
addRangeCheck(ctx, '<', schema.minimum, 'at least')
end
...
endThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for delay. I incorporated your improvement.
membphis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change to new way
|
ping @ypnos |
|
@spacewander do you have time to look at this PR? many thx |
Current messages for
minimumandmaximumwere misleading for a wide audience. Messages are now changed to "at least" forminimumand "at most" formaximum.Code simplified.