jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

propertyNames validation is missing

Open ypnos opened this issue 4 years ago • 3 comments

Currently it always returns true.

I cannot help out with this right now, this issue is to document the shortcoming so other users are aware.

ypnos avatar Oct 08 '20 10:10 ypnos

please provide a mini example, we need it to confirm this issue

membphis avatar Oct 08 '20 12:10 membphis

Example LUA code:

local schema = {
  type = 'object',
  propertyNames = {
    minLength = 4
  },
}
local model = {
  Foo = true
}
local options = {match_pattern=function () return true end, name="Test"}
local validator = JsonSchema.generate_validator(schema, options)
local isValid, errorStr = validator(model)
print(isValid, errorStr)

Expected output: false property name too short Observed output: true nil

When using online validators, I receive the expected output with the following input.

JSON schema:

{
  "type": "object",
  "propertyNames": { "minLength": 4 }
}

JSON model:

{
  "Foo": true
}

ypnos avatar Oct 08 '20 13:10 ypnos

@ypnos that is a todo feature, take a look at:

https://github.com/api7/jsonschema/blob/f8d2f40f9a3489a0c9430b81a40483982fdaa5f0/t/draft6.lua#L32 https://github.com/api7/jsonschema/blob/09dc6ed0524791c26772746a14cb4f83caeefc36/t/draft7.lua#L32

welcome PR to fix it

membphis avatar Oct 09 '20 01:10 membphis