Comparison

util/jsonschema.lua @ 11441:75a280e6e046

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.
author Kim Alvefur <zash@zash.se>
date Tue, 09 Mar 2021 02:33:28 +0100
parent 11440:d5288c99bb5a
child 11442:95f0d77175ca
comparison
equal deleted inserted replaced
11440:d5288c99bb5a 11441:75a280e6e046
55 end 55 end
56 56
57 type_validators.integer = type_validators.number 57 type_validators.integer = type_validators.number
58 58
59 local function validate(schema, data) 59 local function validate(schema, data)
60 if type(schema) == "boolean" then
61 return schema
62 end
60 if type(schema) == "string" then 63 if type(schema) == "string" then
61 return simple_validate(schema, data) 64 return simple_validate(schema, data)
62 end 65 end
63 if type(schema) == "table" then 66 if type(schema) == "table" then
64 if schema.allOf then 67 if schema.allOf then