From 3b09756601a673a51408d70ca94001833545daec Mon Sep 17 00:00:00 2001 From: philc Date: Tue, 10 Sep 2024 16:40:27 +0200 Subject: [PATCH] modif checkjson to remove unknow propertie at check data --- apxtri.js | 3 +++ models/Checkjson.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apxtri.js b/apxtri.js index 93e4f83..859b94b 100755 --- a/apxtri.js +++ b/apxtri.js @@ -142,6 +142,9 @@ if (log) { ); } +//Listen event file for each tribe +// @TODO à ajouter ici + app.listen(conf.api.port, () => { let webaccess = `api waits request on port:${conf.api.port} for`; conf.dns.forEach((u) => { diff --git a/models/Checkjson.js b/models/Checkjson.js index 97ce29b..68a20fd 100755 --- a/models/Checkjson.js +++ b/models/Checkjson.js @@ -204,8 +204,14 @@ Checkjson.schema.data = (schema, data, withschemacheck) => { // properties ={prop1:{type,format},prop2:{type:object,...}} // subdata={prop1,prop2} // Return [] => no error, else 1 item per error {msg,ref:checkjson,data} + const propertielist=Object.keys(properties); + Object.keys(subdata).forEach(kdata=>{ + if (!propertielist.includes(kdata)){ + delete subdata[kdata]; + } + }) let multimsg=[] - Object.keys(properties).forEach((p) => { + propertielist.forEach((p) => { //type is mandatory in a propertie if (subdata[p]) { if (properties[p].properties){