Software /
code /
prosody
Comparison
teal-src/util/jsonschema.tl @ 11448:1d84b54ba0d7
util.jsonschema: Restructure "type" keyword handling
More in line with the other tests
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 09 Mar 2021 14:31:11 +0100 |
parent | 11447:7ad137fe665b |
child | 11449:dabd1fae0540 |
comparison
equal
deleted
inserted
replaced
11447:7ad137fe665b | 11448:1d84b54ba0d7 |
---|---|
190 return validate(schema["else"], data) | 190 return validate(schema["else"], data) |
191 end | 191 end |
192 end | 192 end |
193 end | 193 end |
194 | 194 |
195 if not simple_validate(schema.type, data) then | |
196 return false | |
197 end | |
198 | |
199 if schema.const ~= nil and schema.const ~= data then | 195 if schema.const ~= nil and schema.const ~= data then |
200 return false | 196 return false |
201 end | 197 end |
202 | 198 |
203 if schema["enum"] ~= nil then | 199 if schema["enum"] ~= nil then |
207 end | 203 end |
208 end | 204 end |
209 return false | 205 return false |
210 end | 206 end |
211 | 207 |
212 local validator = type_validators[schema.type] | 208 if schema.type then |
213 if not validator then | 209 if not simple_validate(schema.type, data) then |
214 return true | 210 return false |
215 end | 211 end |
216 | 212 |
217 return validator(schema, data) | 213 local validator = type_validators[schema.type] |
214 if validator then | |
215 return validator(schema, data) | |
216 end | |
217 end | |
218 return true | |
218 end | 219 end |
219 end | 220 end |
220 | 221 |
221 type_validators.table = function (schema : schema_t, data : any) : boolean | 222 type_validators.table = function (schema : schema_t, data : any) : boolean |
222 if data is table then | 223 if data is table then |