fix bug with propertie *
This commit is contained in:
		| @@ -191,7 +191,7 @@ Checkjson.schema.validation = (schema) => { | ||||
|  * @param {*} data some data to check using schema | ||||
|  * @param {*} withschemacheck boolean that force a schema check (usefull on modification schema) | ||||
|  * @returns {status: 200, ref:"Checkjson", msg:"validcheck", data:{itm:object}} | ||||
|  *          {status:417, multimsg:[{re,msg,data}],data:{itm:object}} | ||||
|  *          {status:417, multimsg:[{re,msg,data}],data:{itm:object}} itm with only valid data | ||||
|  */ | ||||
| Checkjson.schema.data = (schema, data, withschemacheck) => { | ||||
|   /* validate a data set with a schema in a context ctx */ | ||||
| @@ -206,12 +206,14 @@ Checkjson.schema.data = (schema, data, withschemacheck) => { | ||||
|     // subdata={prop1,prop2} | ||||
|     // Return [] => no error, else 1 item per error {msg,ref:checkjson,data} | ||||
|     const propertielist = Object.keys(properties); | ||||
|     console.log(propertielist); | ||||
|     Object.keys(subdata).forEach((kdata) => { | ||||
|       if (!propertielist.includes(kdata)) { | ||||
|         delete subdata[kdata]; | ||||
|       } | ||||
|     }); | ||||
|     if (!propertielist.includes("*")) { | ||||
|       // case properties is not any  (*) then delete propertie | ||||
|       Object.keys(subdata).forEach((kdata) => { | ||||
|         if (!propertielist.includes(kdata)) { | ||||
|           delete subdata[kdata]; | ||||
|         } | ||||
|       }); | ||||
|     } | ||||
|     let multimsg = []; | ||||
|     propertielist.forEach((p) => { | ||||
|       //type is mandatory in a propertie | ||||
| @@ -364,7 +366,6 @@ Checkjson.schema.data = (schema, data, withschemacheck) => { | ||||
|   } | ||||
|   let multi = propertiescheck(schema.properties, data); | ||||
|   const res = {}; | ||||
|  | ||||
|   if (multi.length > 0) { | ||||
|     res.status = 417; | ||||
|     res.multimsg = multi; | ||||
|   | ||||
| @@ -514,6 +514,7 @@ Odmdb.r = (objectPathname, apxid, role) => { | ||||
|  * Convert profils in accessright | ||||
|  * @param {*} apxaccessright from schema object {profilname:{R}} | ||||
|  * @param {*} role {xprofils,xalias} accessible after isAuthenticated | ||||
|  * @param {*} properties  array of properties in case accessright is set at [] it means we allow all properties of the schema | ||||
|  * @returns access right  to C create if present, to read (properties list or all if empty), to Update properties list or all if empty, D elete | ||||
|  * example: {"C":[],"R":[properties list],"U":[properties ist],"D":[]} | ||||
|  */ | ||||
| @@ -522,7 +523,6 @@ Odmdb.accessright = (apxaccessrights, role, properties) => { | ||||
|   //if (log) console.log(currentmod,"role",role) | ||||
|   //if (log) console.log(currentmod,"properties",properties) | ||||
|   const accessright = {}; | ||||
|   console.log(); | ||||
|   role.xprofils.forEach((p) => { | ||||
|     if (apxaccessrights[p]) { | ||||
|       Object.keys(apxaccessrights[p]).forEach((act) => { | ||||
| @@ -687,7 +687,6 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => { | ||||
|       //console.log(k, itmtostore[k], itmtostore[k] === ""); | ||||
|       if (itmtostore[k] === "") delete itmtostore[k]; | ||||
|     }); | ||||
|  | ||||
|     Object.keys(itmtostore).forEach((k) => { | ||||
|       //Manage base64 case image to convert ans store in webp | ||||
|       if (k.includes("imgbase64_") && itmtostore[k] != "") { | ||||
|   | ||||
| @@ -129,10 +129,10 @@ Wwws.initlocaldata = (tribe, appname, pagename, version, profils, lg) => { | ||||
|   if (loc.tpl) { | ||||
|     Object.keys(loc.tpl).forEach((r) => { | ||||
|       let src = `../${loc.tpl[r]}`; | ||||
|       //console.log(path.resolve(src)) | ||||
|       if (!fs.existsSync(src)) { | ||||
|         src += `_${lg}.mustache`; | ||||
|       } | ||||
|       //console.log(path.resolve(src)) | ||||
|       if (fs.existsSync(src)) { | ||||
|         localstorage.tpl[r] = fs.readFileSync(src,'utf-8'); | ||||
|       } else { | ||||
|   | ||||
| @@ -599,7 +599,7 @@ router.get( | ||||
|     "frenchlocation": { | ||||
|       "title": "Location", | ||||
|       "description": "use franch gov refential to locaize", | ||||
|       "$ref": "nationchains/schema/frenchlocation" | ||||
|       "$ref": "adminapi/schema/frenchlocation" | ||||
|     }, | ||||
|     "denomination": { | ||||
|       "title": "Company name", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user