modif checkjson to remove unknow propertie at check data

This commit is contained in:
2024-09-10 16:40:27 +02:00
parent 305e3c2645
commit 3b09756601
2 changed files with 10 additions and 1 deletions

View File

@@ -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){