Comparison

teal-src/util/jsonschema.tl @ 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
134 return true 134 return true
135 end 135 end
136 136
137 type_validators.integer = type_validators.number 137 type_validators.integer = type_validators.number
138 138
139 local function validate(schema : schema_t | type_e, data : any) : boolean 139 local function validate(schema : schema_t | type_e | boolean, data : any) : boolean
140 if schema is boolean then
141 return schema
142 end
140 if schema is type_e then 143 if schema is type_e then
141 return simple_validate(schema, data) 144 return simple_validate(schema, data)
142 end 145 end
143 if schema is schema_t then 146 if schema is schema_t then
144 if schema.allOf then 147 if schema.allOf then