From 1317e78fbb50d585d3f0aa55262690db8c096026 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 9 Mar 2021 02:43:50 +0100 Subject: util.jsonschema: Implement "propertyNames" This is a bit special in Lua as tables are not limited to string keys --- util/jsonschema.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util/jsonschema.lua') diff --git a/util/jsonschema.lua b/util/jsonschema.lua index 5ba33900..0723a45e 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -158,6 +158,9 @@ type_validators.table = function(schema, data) if schema.properties then local additional = schema.additionalProperties or true for k, v in pairs(data) do + if schema.propertyNames and not validate(schema.propertyNames, k) then + return false + end local s = schema.properties[k] or additional if not validate(s, v) then return false @@ -165,6 +168,9 @@ type_validators.table = function(schema, data) end elseif schema.additionalProperties then for k, v in pairs(data) do + if schema.propertyNames and not validate(schema.propertyNames, k) then + return false + end if not validate(schema.additionalProperties, v) then return false end -- cgit v1.2.3