Diff

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
line wrap: on
line diff
--- a/teal-src/util/jsonschema.tl	Tue Mar 09 02:26:05 2021 +0100
+++ b/teal-src/util/jsonschema.tl	Tue Mar 09 02:33:28 2021 +0100
@@ -136,7 +136,10 @@
 
 type_validators.integer = type_validators.number
 
-local function validate(schema : schema_t | type_e, data : any) : boolean
+local function validate(schema : schema_t | type_e | boolean, data : any) : boolean
+	if schema is boolean then
+		return schema
+	end
 	if schema is type_e then
 		return simple_validate(schema, data)
 	end