util.jsonschema: Allow a boolean as schema

Apparently a schema must be either an object or a boolean. Not sure
where I got this string shortcut from, but I think I will keep it as it
is very convenient.
This commit is contained in:
Kim Alvefur 2021-03-09 02:33:28 +01:00
parent 6a7346ac8e
commit 5a44c4a32b
2 changed files with 7 additions and 1 deletions

View file

@ -57,6 +57,9 @@ end
type_validators.integer = type_validators.number
local function validate(schema, data)
if type(schema) == "boolean" then
return schema
end
if type(schema) == "string" then
return simple_validate(schema, data)
end