|
|
|
@ -60,7 +60,7 @@ module.exports = function (templateInfo, fileName) { |
|
|
|
|
//check empty fields
|
|
|
|
|
for (const key in templateInfo) { |
|
|
|
|
if (!templateInfo[key]) { |
|
|
|
|
throw({ |
|
|
|
|
throw ({ |
|
|
|
|
eCode: 406, |
|
|
|
|
eText: 'هیچ یک از فیلدها نباید خالی باشند' |
|
|
|
|
}) |
|
|
|
@ -73,7 +73,7 @@ module.exports = function (templateInfo, fileName) { |
|
|
|
|
let inspectModule = new InspectModule(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
doc = new Docxtemplater(zip,{ |
|
|
|
|
doc = new Docxtemplater(zip, { |
|
|
|
|
modules: [inspectModule] |
|
|
|
|
}); |
|
|
|
|
} catch (error) { |
|
|
|
@ -82,13 +82,13 @@ module.exports = function (templateInfo, fileName) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let postParsed = inspectModule.inspect.postparsed; |
|
|
|
|
let tags = Object.keys(getTags(postParsed)) |
|
|
|
|
let placeholders = Object.keys(getTags(postParsed)) |
|
|
|
|
let templateInfoKeys = Object.keys(templateInfo) |
|
|
|
|
|
|
|
|
|
//compare template tags and received fields from client(templateInfo)
|
|
|
|
|
for(let i = 0; i < tags.length; i++){ |
|
|
|
|
if(!templateInfoKeys.includes(tags[i]) ){ |
|
|
|
|
throw({ |
|
|
|
|
//compare template placeholders and received fields from client(templateInfo)
|
|
|
|
|
for (let i = 0; i < placeholders.length; i++) { |
|
|
|
|
if (!templateInfoKeys.includes(placeholders[i])) { |
|
|
|
|
throw ({ |
|
|
|
|
eCode: 406, |
|
|
|
|
eText: 'اطلاعات وارد شده ناقص است' |
|
|
|
|
}) |
|
|
|
|