module.exports.logindatacheck = async function (req, res) { if (req.body.username == "" || req.body.username == undefined || req.body.username == null) { return { status: false, data: {}, errors: "Please enter Username" } } if (req.body.password == "" || req.body.password == undefined || req.body.password == null) { return { status: false, data: {}, errors: "Please enter Password" } } return { status: true }; } module.exports.createContactentrycheck = async function (req, res) { if (req.body.contact_for == "" || req.body.contact_for == undefined || req.body.contact_for == null) { return { status: false, data: [], errors: "Please enter Customer ID of contact" } } if (req.body.first_name == "" || req.body.first_name == undefined || req.body.first_name == null) { return { status: false, data: [], errors: "Please enter First Name" } } if (req.body.last_name == "" || req.body.last_name == undefined || req.body.last_name == null) { return { status: false, data: [], errors: "Please enter Last Name" } } if (req.body.mobile_no == "" || req.body.mobile_no == undefined || req.body.mobile_no == null) { return { status: false, data: [], errors: "Please enter Mobile No." } } if(req.body.mobile_no !=null && req.body.mobile_no !=""){ if(req.body.mobile_no.length != 10 ){ return { status: false, data: [], errors: "Please enter valid Mobile No" } } } // console.log("req.body.email_id",req.body.email_id); // console.log("req.body.mobile_no",req.body.mobile_no); if (req.body.email_id == "" || req.body.email_id == undefined || req.body.email_id == null) { return { status: false, data: [], errors: "Please enter Email ID." } } if(req.body.email_id != null && req.body.email_id != ""){ console.log("check valid email"); if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(req.body.email_id)){ console.log("valid email"); }else{ console.log("in vliad email"); return { status: false, data: [], errors: "Please enter valid Email ID" } } } if (req.body.department == "" || req.body.department == undefined || req.body.department == null) { return { status: false, data: [], errors: "Please enter Department" } } if (req.body.function == "" || req.body.function == undefined || req.body.function == null) { return { status: false, data: [], errors: "Please enter Functional Area" } } if (req.body.created_by == "" || req.body.created_by == undefined || req.body.created_by == null) { return { status: false, data: [], errors: "Please enter Login ID" } } return { status: true }; } module.exports.getdvrDetailscheck = async (req, res) => { if (req.query.dvrid == "" || req.query.dvrid == undefined || req.query.dvrid == null) { return { status: false, data: {}, errors: "Please enter DVR ID" } } return { status: true }; } module.exports.createDvrentrycheck = async function (req, res) { if (req.body.visit_date == "" || req.body.visit_date == undefined || req.body.visit_date == null) { return { status: false, data: [], errors: "Please enter Date of visit" } } if (req.body.customer_name == "" || req.body.customer_name == undefined || req.body.customer_name == null) { return { status: false, data: [], errors: "Please enter Customer Name" } } if (!containsOnlyLetters(req.body.customer_name)) { return { status: false, data: [], errors: " Please Enter Valid Customer Name " } } if (req.body.contact_name == "" || req.body.contact_name == undefined || req.body.contact_name == null) { return { status: false, data: [], errors: "Please enter Contact Name" } } if (req.body.message == "" || req.body.message == undefined || req.body.message == null) { return { status: false, data: [], errors: "Please enter Meassage" } } if (req.body.physical_metting == "" || req.body.physical_metting == undefined || req.body.physical_metting == null) { return { status: false, data: [], errors: "Please enter Designation" } } if (req.body.stage_id == "" || req.body.stage_id == undefined || req.body.stage_id == null) { return { status: false, data: [], errors: "Please choose Status " } } if (req.body.created_by == "" || req.body.created_by == undefined || req.body.created_by == null) { return { status: false, data: [], errors: "Please enter Login ID" } } // if (req.body.sale_person == "" || req.body.sale_person == undefined || req.body.sale_person == null) { // return { status: false, data: [], errors: "Please enter Login ID" } // } // if (req.body.second_contact == "" || req.body.second_contact == undefined || req.body.second_contact == null) { // return { status: false, data: [], errors: "Please enter Login ID" } // } // if (req.body.nextstep == "" || req.body.nextstep == undefined || req.body.nextstep == null) { // return { status: false, data: [], errors: "Please enter Login ID" } // } // if (req.body.objective == "" || req.body.objective == undefined || req.body.objective == null) { // return { status: false, data: [], errors: "Please enter Login ID" } // } // if (req.body.est_Date == "" || req.body.est_Date == undefined || req.body.est_Date == null) { // return { status: false, data: [], errors: "Please enter Login ID" } // } // if (req.body.estvalue == "" || req.body.estvalue == undefined || req.body.estvalue == null) { // return { status: false, data: [], errors: "Please enter Login ID" } // } return { status: true }; } module.exports.updatedvrDetailscheck = async (req, res) => { if (req.body.dvr_id == "" || req.body.dvr_id == undefined || req.body.dvr_id == null) { return { status: false, data: [], errors: "Please enter DVR ID" } } if (req.body.visit_date == "" || req.body.visit_date == undefined || req.body.visit_date == null) { return { status: false, data: [], errors: "Please enter Date of visit" } } if (req.body.customer_name == "" || req.body.customer_name == undefined || req.body.customer_name == null) { return { status: false, data: [], errors: "Please enter Customer Name" } } if (req.body.contact_name == "" || req.body.contact_name == undefined || req.body.contact_name == null) { return { status: false, data: [], errors: "Please enter Contact Name" } } if (req.body.message == "" || req.body.message == undefined || req.body.message == null) { return { status: false, data: {}, errors: "Please enter Mesasge" } } if (req.body.physical_metting == "" || req.body.physical_metting == undefined || req.body.physical_metting == null) { return { status: false, data: {}, errors: "Please enter Physical Metting status" } } if (req.body.stage_id == "" || req.body.stage_id == undefined || req.body.stage_id == null) { return { status: false, data: {}, errors: "Please choose Status" } } if (req.body.updated_by == "" || req.body.updated_by == undefined || req.body.updated_by == null) { return { status: false, data: {}, errors: "Please enter Login ID for updation." } } return { status: true }; } module.exports.signupCheck = async function (req, res) { if (req.body.login_id == "" || req.body.login_id == undefined || req.body.login_id == null) { return { status: false, data: {}, errors: "Please enter Login Id" } } if (req.body.customer_id == "" || req.body.customer_id == undefined || req.body.customer_id == null) { return { status: false, data: {}, errors: "Please enter Customer Id" } } if (req.body.password == "" || req.body.password == undefined || req.body.password == null) { return { status: false, data: {}, errors: "Please enter Password" } } // if (req.body.password.length != '8'){ // return { status: false, data: {}, errors: "Please enter 8 digits Password" } // } if (req.body.first_name == "" || req.body.first_name == undefined || req.body.first_name == null) { return { status: false, data: {}, errors: "Please enter First Name" } } if (req.body.last_name == "" || req.body.last_name == undefined || req.body.last_name == null) { return { status: false, data: {}, errors: "Please enter Last Name" } } if (req.body.email == "" || req.body.email == undefined || req.body.email == null) { return { status: false, data: {}, errors: "Please enter Email" } } if (req.body.mobile_number == "" || req.body.mobile_number == undefined || req.body.mobile_number == null) { return { status: false, data: {}, errors: "Please enter Mobile Number" } } if (req.body.mobile_number.length != '10') { return { status: false, data: {}, errors: "Please Enter 10 digit Mobile Number" } } return { status: true }; } module.exports.userrolemapcheck = async function (req, res) { if (req.body.login_id == "" || req.body.login_id == undefined || req.body.login_id == null) { return { status: false, data: {}, errors: "Please enter login id" } } if (req.body.user_role_id == "" || req.body.user_role_id == undefined || req.body.user_role_id == null) { return { status: false, data: {}, errors: "Please enter user role id" } } return { status: true }; } module.exports.createCustomerentrycheck = async function (req, res) { if (req.body.customer_name == "" || req.body.customer_name == undefined || req.body.customer_name == null) { return { status: false, data: {}, errors: "Please enter Valid Customer Name" } } if (!containsOnlyLetters(req.body.customer_name)) { return { status: false, data: {}, errors: "Please enter Valid Customer Name" } } if (req.body.sale_person == "" || req.body.sale_person == undefined || req.body.sale_person == null) { return { status: false, data: {}, errors: "Please enter Valid Sales Person Name" } } if (req.body.created_by == "" || req.body.created_by == undefined || req.body.created_by == null) { return { status: false, data: {}, errors: "Please enter Login ID" } } return { status: true }; } module.exports.updateContactDetailscheck = async (req, res) => { var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; if (req.body.contact_id == "" || req.body.contact_id == undefined || req.body.contact_id == null) { return { status: false, data: {}, errors: "Please enter contact Id" } } if (req.body.customer_id == "" || req.body.customer_id == undefined || req.body.customer_id == null) { return { status: false, data: {}, errors: "Please enter Customer Id" } } if (req.body.first_name == "" || req.body.first_name == undefined || req.body.first_name == null) { return { status: false, data: {}, errors: "Please enter First Name" } } if (req.body.last_name == "" || req.body.last_name == undefined || req.body.last_name == null) { return { status: false, data: {}, errors: "Please enter Last Name" } } if (req.body.mobile_number == "" || req.body.mobile_number == undefined || req.body.mobile_number == null) { return { status: false, data: {}, errors: "Please enter Mobile Number" } } if (req.body.mobile_number.length != '10') { return { status: false, data: {}, errors: "Please enter 10 digits Mobile Number" } } if (req.body.email_id == "" || req.body.email_id == undefined || req.body.email_id == null) { console.log("req.body.email_id", req.body.email_id); return { status: false, data: {}, errors: "Please enter Email Id" } } // console.log("req.body.email_id",req.body.email_id); //console.log("check validation",req.body.email_id.match(validRegex)); // if(req.body.email_id.match(validRegex) == false){ // return { status: false, data: {}, errors: "Please enter valid Email ID" } // } if (req.body.designation == "" || req.body.designation == undefined || req.body.designation == null) { return { status: false, data: {}, errors: "Please enter Designation" } } if (req.body.department == "" || req.body.department == undefined || req.body.department == null) { return { status: false, data: {}, errors: "Please enter Department" } } if (req.body.updated_by == "" || req.body.updated_by == undefined || req.body.updated_by == null) { return { status: false, data: {}, errors: "Please enter Login ID for updation " } } return { status: true }; } module.exports.updateCustomerDetailscheck = async (req, res) => { if (req.body.customer_id == "" || req.body.customer_id == undefined || req.body.customer_id == null) { return { status: false, data: {}, errors: "Please enter contact Id" } } if (req.body.customer_name == "" || req.body.customer_name == undefined || req.body.customer_name == null) { return { status: false, data: {}, errors: "Please enter Customer Name" } } if (!containsOnlyLetters(req.body.customer_name)) { return { status: false, data: {}, errors: " Please Enter Valid Customer Name ." } } if (req.body.updated_by == "" || req.body.updated_by == undefined || req.body.updated_by == null) { return { status: false, data: {}, errors: "Please enter Login ID for updation " } } return { status: true }; } module.exports.mappingCustomerDetailsCheck = async (req, res) => { if (req.query.sale_person == "" || req.query.sale_person == undefined || req.query.sale_person == null) { return { status: false, data: {}, errors: "Please enter sale person" } } return { status: true }; } module.exports.mappingFuncIDToPersonNamesCheck = async (req, res) => { if (req.query.func_id == "" || req.query.func_id == undefined || req.query.func_id == null) { return { status: false, data: {}, errors: "Please enter func id" } } return { status: true }; } function containsOnlyLetters(str) { //return /^[A-Za-z\s]+$/.test(str); return /^[ A-Za-z_@./#&+-]*$/.test(str); }