From 39efd42af1102fa763df41f2e5f6f3f0e5aee0a7 Mon Sep 17 00:00:00 2001 From: Sanjaysinh Zala Date: Fri, 12 Oct 2018 12:16:00 +0530 Subject: [PATCH] server side validation bug fixes --- client/src/components/pdmedit.vue | 29 +++++++++++++++++-- .../validation_rules/product_information.js | 12 ++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/client/src/components/pdmedit.vue b/client/src/components/pdmedit.vue index 59bf518..640bb1a 100644 --- a/client/src/components/pdmedit.vue +++ b/client/src/components/pdmedit.vue @@ -217,7 +217,7 @@ export default { let shippingData = null let inventoryData = null - let keyToDelete = ['activeSummary', 'createdAt', 'import-tracker_id', 'max_price', 'min_price', 'username', 'supplier_info', 'vid', 'tags', 'attributes', 'images', 'inventory', 'pricing', 'imprint_data', 'shipping', 'features'] + let keyToDelete = ['activeSummary', 'createdAt', 'import-tracker_id', 'max_price', 'min_price', 'username', 'supplier_info', 'vid', 'tags', 'product_tags', 'attributes', 'images', 'inventory', 'pricing', 'imprint_data', 'shipping', 'features'] keyToDelete.forEach(e => { delete productData[e] }); if (this.activetab === 1) { @@ -687,7 +687,20 @@ export default { }, vid: { type: "array", - title: "vid" + title: "vid", + options: { + hidden: true + } + }, + releated_sku: { + type: "array", + title: "Related SKU", + items: { + type: 'string' + }, + options: { + disable_array_reorder: true + } }, tags: { type: "array", @@ -700,6 +713,18 @@ export default { }, propertyOrder: 43 }, + product_tags: { + type: "array", + title: "Product Tags", + items: { + type: 'string' + }, + options: { + disable_array_reorder: true, + hidden: true + }, + propertyOrder: 43 + }, 'non-available_regions': { type: "array", title: 'Non-Available Regions', diff --git a/service/src/validation_rules/product_information.js b/service/src/validation_rules/product_information.js index 35eefb0..6e69147 100644 --- a/service/src/validation_rules/product_information.js +++ b/service/src/validation_rules/product_information.js @@ -95,7 +95,7 @@ let currentDate = new Date().toISOString().slice(0,10); errorString: "Matrix_Price field invalid, please input numeric value", errorCode: 'Matrix_PriceRegEx400', qryMongo : {$and:[{ "matrix_price": { $exists: true, $ne: "" } },{ "matrix_price" : {$not: /^\d{0,8}(\.\d{0,4})?$/ }}]}, - qryObject: (matrix_price)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (matrix_price == undefined) { return true } else if(!regExp.test(matrix_price)) { return true } else { return false } }, + qryObject: (matrix_price)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (matrix_price == undefined) { return true } else if(matrix_price !== '' && !regExp.test(matrix_price)) { return true } else { return false } }, qryErrStr: "Matrix_Price field invalid, please input numeric value" }, { @@ -122,7 +122,7 @@ let currentDate = new Date().toISOString().slice(0,10); errorCode: 'Matrix_FreightRegEx400', qryMongo : {$and: [{ "matrix_frieght": { $exists: true, $ne: "" } }, { "matrix_frieght" : {$not: /^\d{0,8}(\.\d{0,4})?$/ }}]}, - qryObject: (matrix_frieght)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (matrix_frieght == undefined) { return true; } else if(!regExp.test(matrix_frieght)) { return true; } else { return false; } }, + qryObject: (matrix_frieght)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (matrix_frieght == undefined) { return true; } else if(matrix_frieght !== '' && !regExp.test(matrix_frieght)) { return true; } else { return false; } }, qryErrStr: "Matrix_Freight field invalid, please input numeric value" }, { @@ -131,7 +131,7 @@ let currentDate = new Date().toISOString().slice(0,10); errorCode: 'VatRegEx400', qryMongo : {$and: [{ "vat": { $exists: true, $ne: "" } }, { "vat" : {$not: /^\d{0,8}(\.\d{0,4})?$/ }}]}, - qryObject: (vat)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (vat == undefined) { return true } else if(!regExp.test(vat)) { return true; } else { return false; } }, + qryObject: (vat)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (vat == undefined) { return true } else if(vat !== '' && !regExp.test(vat)) { return true; } else { return false; } }, qryErrStr: "vat field invalid, please input numeric value" }, { @@ -140,7 +140,7 @@ let currentDate = new Date().toISOString().slice(0,10); errorCode: 'packaging_chargesRegEx400', qryMongo : {$and: [{ "packaging_charges": { $exists: true, $ne: "" } }, { "packaging_charges" : {$not: /^\d{0,8}(\.\d{0,4})?$/ }}]}, - qryObject: (packaging_charges)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (packaging_charges == undefined) { return true; } else if(!regExp.test(packaging_charges)) { return true; } else { return false; } }, + qryObject: (packaging_charges)=>{ let regExp = new RegExp(/^\d{0,8}(\.\d{0,4})?$/); if (packaging_charges == undefined) { return true; } else if(packaging_charges !== '' && !regExp.test(packaging_charges)) { return true; } else { return false; } }, qryErrStr: "Packaging_Charges field invalid, please input numeric value" }, { @@ -150,7 +150,7 @@ let currentDate = new Date().toISOString().slice(0,10); qryMongo : {$and: [{ "video_url": { $exists: true, $ne: "" } }, { "video_url" : {$not: /https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/ }}]}, - qryObject: (video_url)=>{ let regExp = new RegExp(/https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*$?/); if (video_url == undefined) { return true; } else if(!regExp.test(video_url)) { return true; } else { return false; } }, + qryObject: (video_url)=>{ let regExp = new RegExp(/https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/); if (video_url == undefined) { return true; } else if( video_url !== '' && !regExp.test(video_url)) { return true; } else { return false; } }, qryErrStr: "Video_URL field invalid, please input a valid URL" }, { @@ -160,7 +160,7 @@ let currentDate = new Date().toISOString().slice(0,10); qryMongo : {$and: [{ "distributor_central_url": { $exists: true, $ne: "" } }, { "distributor_central_url" : {$not: /https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/ }}]}, - qryObject: (distributor_central_url)=>{ let regExp = new RegExp(/https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/); if (distributor_central_url == undefined) { return true; } else if(!regExp.test(distributor_central_url)) { return true; } else { return false; } }, + qryObject: (distributor_central_url)=>{ let regExp = new RegExp(/https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/); if (distributor_central_url == undefined) { return true; } else if(distributor_central_url !== '' && !regExp.test(distributor_central_url)) { return true; } else { return false; } }, qryErrStr: "Distributor_Central_URL field invalid, please input a valid URL" } ];