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

why return false if input data is not empty when required set a empty array? #46

Open
lockdown56 opened this issue Dec 2, 2020 · 0 comments
Labels

Comments

@lockdown56
Copy link

I found this code in jsonschema.lua

if schema.required and #schema.required == 0 then
     -- return false if the input data is not empty
     ctx:stmt(sformat('if %s ~= 1 then', datakind))
     ctx:stmt(        '  return false, "the input data should be an empty table"')
     ctx:stmt(        'end')
end

if this, when I have a schema

{
    "type": "object",
    "properties": {
        "name": { "type": "string" }
    },
    "required": []
}

and a json object

{
  "name": "Tom"
}

such will return an err: the input data should be an empty table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants