fix
This commit is contained in:
@@ -4,6 +4,7 @@ const { res404, res500 } = require('../plugins/controllersHelperFunctions')
|
||||
const _faSr = _sr.fa
|
||||
const { checkValidations } = require('../plugins/controllersHelperFunctions')
|
||||
const Survey = require('../models/Survey')
|
||||
const Transaction = require('../models/Transaction')
|
||||
|
||||
module.exports.create = [
|
||||
(req, res) => {
|
||||
@@ -47,6 +48,18 @@ module.exports.createPublic = [
|
||||
body('national').notEmpty().withMessage(_faSr.required.national_code),
|
||||
body('phoneNumber').notEmpty().isMobilePhone('ir-IR').withMessage(_faSr.required.phone_number),
|
||||
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),
|
||||
(req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user