Skip to content

Commit

Permalink
edit validation
Browse files Browse the repository at this point in the history
Relates #26
  • Loading branch information
alaa-yasin committed Sep 23, 2019
1 parent 70c8a20 commit e06e253
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions server/controllers/postFeedback.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
const Joi = require('@hapi/joi');
const postFeedback = require('../database/config/connection');
const feedbackSchema = require('../validation/feedback');

const PostFeedback = (req, res, next) => {
Joi.validate(req.body, feedbackSchema, (err) => {
feedbackSchema.validate(req.body, (err) => {
if (err) {
// eslint-disable-next-line no-console
console.log(err); // it is gonna be changed later
res.send('fill all the fields');
} else {
postFeedback(req.body)
.then(res.send({ code: 200 }))
.then(res.send('Your feedback has sent!'))
.catch((error) => next(error));
}
});
Expand Down

0 comments on commit e06e253

Please sign in to comment.