forked from apxtri/apxtri
fix issue with integer at 0
This commit is contained in:
parent
6d81688dde
commit
784bb6f6f3
@ -17,9 +17,9 @@ Checkjson.schema.properties.type.object = (val) =>
|
|||||||
Checkjson.schema.properties.type.number = (n) => typeof n === "number";
|
Checkjson.schema.properties.type.number = (n) => typeof n === "number";
|
||||||
Checkjson.schema.properties.type.boolean = (n) => typeof n === "boolean";
|
Checkjson.schema.properties.type.boolean = (n) => typeof n === "boolean";
|
||||||
Checkjson.schema.properties.type.integer = (n) =>
|
Checkjson.schema.properties.type.integer = (n) =>
|
||||||
n != "" && !isNaN(n) && Math.round(n) == n;
|
n !== "" && !isNaN(n) && Math.round(n) === n;
|
||||||
Checkjson.schema.properties.type.float = (n) =>
|
Checkjson.schema.properties.type.float = (n) =>
|
||||||
n != "" && !isNaN(n) && Math.round(n) != n; //not yet in json schema
|
n !== "" && !isNaN(n) && Math.round(n) !== n; //not yet in json schema
|
||||||
Checkjson.schema.properties.minLength = (str, min) =>
|
Checkjson.schema.properties.minLength = (str, min) =>
|
||||||
typeof str === "string" && str.length >= parseInt(min);
|
typeof str === "string" && str.length >= parseInt(min);
|
||||||
Checkjson.schema.properties.maxLength = (str, max) =>
|
Checkjson.schema.properties.maxLength = (str, max) =>
|
||||||
@ -206,6 +206,7 @@ Checkjson.schema.data = (schema, data, withschemacheck) => {
|
|||||||
// subdata={prop1,prop2}
|
// subdata={prop1,prop2}
|
||||||
// Return [] => no error, else 1 item per error {msg,ref:checkjson,data}
|
// Return [] => no error, else 1 item per error {msg,ref:checkjson,data}
|
||||||
const propertielist = Object.keys(properties);
|
const propertielist = Object.keys(properties);
|
||||||
|
|
||||||
Object.keys(subdata).forEach((kdata) => {
|
Object.keys(subdata).forEach((kdata) => {
|
||||||
if (!propertielist.includes(kdata)) {
|
if (!propertielist.includes(kdata)) {
|
||||||
delete subdata[kdata];
|
delete subdata[kdata];
|
||||||
@ -214,7 +215,7 @@ Checkjson.schema.data = (schema, data, withschemacheck) => {
|
|||||||
let multimsg = [];
|
let multimsg = [];
|
||||||
propertielist.forEach((p) => {
|
propertielist.forEach((p) => {
|
||||||
//type is mandatory in a propertie
|
//type is mandatory in a propertie
|
||||||
if (subdata[p]) {
|
if (subdata.hasOwnProperty(p)) {
|
||||||
if (properties[p].properties) {
|
if (properties[p].properties) {
|
||||||
//means it is a subobject
|
//means it is a subobject
|
||||||
multimsg = multimsg.concat(
|
multimsg = multimsg.concat(
|
||||||
|
@ -553,7 +553,6 @@ Odmdb.accessright = (apxaccessrights, role) => {
|
|||||||
|
|
||||||
Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
||||||
const getschema = Odmdb.Schema(objectPathname, true);
|
const getschema = Odmdb.Schema(objectPathname, true);
|
||||||
|
|
||||||
if (getschema.status != 200) return getschema;
|
if (getschema.status != 200) return getschema;
|
||||||
|
|
||||||
if (!itm[getschema.data.schema.apxid]) {
|
if (!itm[getschema.data.schema.apxid]) {
|
||||||
@ -672,9 +671,11 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
|||||||
itmtostore.dt_update = dayjs().toISOString();
|
itmtostore.dt_update = dayjs().toISOString();
|
||||||
}
|
}
|
||||||
Object.keys(itmtostore).forEach((k) => {
|
Object.keys(itmtostore).forEach((k) => {
|
||||||
// remove undefined itmtostore because empty =>
|
// remove empty itmtostore in case they are =>
|
||||||
if (!itmtostore[k]) delete itmtostore[k];
|
console.log(k, itmtostore[k], itmtostore[k] === "");
|
||||||
|
if (itmtostore[k] === "") delete itmtostore[k];
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(itmtostore).forEach((k) => {
|
Object.keys(itmtostore).forEach((k) => {
|
||||||
//Manage base64 case image to convert ans store in webp
|
//Manage base64 case image to convert ans store in webp
|
||||||
if (k.includes("imgbase64_") && itmtostore[k] != "") {
|
if (k.includes("imgbase64_") && itmtostore[k] != "") {
|
||||||
@ -711,6 +712,7 @@ Odmdb.cud = (objectPathname, crud, itm, role, runindex = true) => {
|
|||||||
});
|
});
|
||||||
if (crud == "C") itmtostore.dt_create = dayjs().toISOString();
|
if (crud == "C") itmtostore.dt_create = dayjs().toISOString();
|
||||||
// check consistency of datatostore
|
// check consistency of datatostore
|
||||||
|
console.log("itmstostore::::::", itmtostore);
|
||||||
const chkdata = Checkjson.schema.data(
|
const chkdata = Checkjson.schema.data(
|
||||||
getschema.data.schema,
|
getschema.data.schema,
|
||||||
itmtostore,
|
itmtostore,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user