fix
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
const { body, validationResult } = require('express-validator')
|
const { body, validationResult } = require('express-validator')
|
||||||
|
|
||||||
const Complaint = require('../models/Complaint')
|
const Complaint = require('../models/Complaint')
|
||||||
|
const Transaction = require('../models/Transaction')
|
||||||
|
|
||||||
const { _sr } = require('../plugins/serverResponses')
|
const { _sr } = require('../plugins/serverResponses')
|
||||||
const { checkValidations } = require('../plugins/controllersHelperFunctions')
|
const { checkValidations } = require('../plugins/controllersHelperFunctions')
|
||||||
const _faSr = _sr.fa
|
const _faSr = _sr.fa
|
||||||
@@ -13,7 +15,14 @@ module.exports.create = [
|
|||||||
body('national').notEmpty().withMessage(_faSr.required.national_code),
|
body('national').notEmpty().withMessage(_faSr.required.national_code),
|
||||||
body('phoneNumber').notEmpty().isMobilePhone('ir-IR').withMessage(_faSr.required.phone_number),
|
body('phoneNumber').notEmpty().isMobilePhone('ir-IR').withMessage(_faSr.required.phone_number),
|
||||||
body('email').notEmpty().isEmail().withMessage(_faSr.required.email),
|
body('email').notEmpty().isEmail().withMessage(_faSr.required.email),
|
||||||
body('receptionCode').notEmpty().withMessage(_faSr.required.field),
|
body('receptionCode').notEmpty().withMessage(_faSr.required.field).custom(async(value, { req }) => {
|
||||||
|
const check = await Transaction.findOne({ItemReceptionTransDate:value})
|
||||||
|
if(!check){
|
||||||
|
return Promise.reject(new Error("کد پذیرش معتبر نیست"))
|
||||||
|
}else{
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
}),
|
||||||
body('caption').notEmpty().withMessage(_faSr.required.caption),
|
body('caption').notEmpty().withMessage(_faSr.required.caption),
|
||||||
body('callType').notEmpty().isBoolean().withMessage(_faSr.required.field),
|
body('callType').notEmpty().isBoolean().withMessage(_faSr.required.field),
|
||||||
body('brand').notEmpty().isBoolean().withMessage(_faSr.required.field),
|
body('brand').notEmpty().isBoolean().withMessage(_faSr.required.field),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const { res404, res500 } = require('../plugins/controllersHelperFunctions')
|
|||||||
const _faSr = _sr.fa
|
const _faSr = _sr.fa
|
||||||
const { checkValidations } = require('../plugins/controllersHelperFunctions')
|
const { checkValidations } = require('../plugins/controllersHelperFunctions')
|
||||||
const Survey = require('../models/Survey')
|
const Survey = require('../models/Survey')
|
||||||
|
const Transaction = require('../models/Transaction')
|
||||||
|
|
||||||
module.exports.create = [
|
module.exports.create = [
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
@@ -47,6 +48,18 @@ module.exports.createPublic = [
|
|||||||
body('national').notEmpty().withMessage(_faSr.required.national_code),
|
body('national').notEmpty().withMessage(_faSr.required.national_code),
|
||||||
body('phoneNumber').notEmpty().isMobilePhone('ir-IR').withMessage(_faSr.required.phone_number),
|
body('phoneNumber').notEmpty().isMobilePhone('ir-IR').withMessage(_faSr.required.phone_number),
|
||||||
body('email').notEmpty().isEmail().withMessage(_faSr.required.email),
|
body('email').notEmpty().isEmail().withMessage(_faSr.required.email),
|
||||||
|
body('code').custom(async(value, { req }) => {
|
||||||
|
if(value){
|
||||||
|
const check = await Transaction.findOne({ItemReceptionTransDate:value})
|
||||||
|
if(!check){
|
||||||
|
return Promise.reject(new Error("کد پذیرش معتبر نیست"))
|
||||||
|
}else{
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
checkValidations(validationResult),
|
checkValidations(validationResult),
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user