POST /condition/new
This commit is contained in:
@ -150,7 +150,7 @@ module.exports = router;
|
||||
|
||||
|
||||
async function numberCheck (sample, res, next) { // validate number, returns false if invalid
|
||||
const sampleData = await SampleModel.findOne({number: sample.number}).lean().exec().catch(err => { return next(err)});
|
||||
const sampleData = await SampleModel.findOne({number: sample.number}).lean().exec().catch(err => {next(err); return false;});
|
||||
if (sampleData) { // found entry with sample number
|
||||
res.status(400).json({status: 'Sample number already taken'});
|
||||
return false
|
||||
@ -159,7 +159,7 @@ async function numberCheck (sample, res, next) { // validate number, returns fa
|
||||
}
|
||||
|
||||
async function materialCheck (sample, res, next, id = sample.material_id) { // validate material_id and color, returns false if invalid
|
||||
const materialData = await MaterialModel.findById(id).lean().exec().catch(err => {next(err);}) as any;
|
||||
const materialData = await MaterialModel.findById(id).lean().exec().catch(err => {next(err); return false;}) as any;
|
||||
if (materialData instanceof Error) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user