Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(req, res, next) => {
// Extract the validation errors from a request.
const errors = validationResult(req);
// Create a BookInstance object with escaped/trimmed data and current id.
var bookinstance = new BookInstance(
{ book: req.body.book,
imprint: req.body.imprint,
status: req.body.status,
due_back: req.body.due_back,
_id: req.params.id
});
if (!errors.isEmpty()) {
// There are errors so render the form again, passing sanitized values and errors.
Book.find({},'title')
.exec(function (err, books) {
if (err) { return next(err); }
// Successful, so render.
], function (req, res, next) {
const errors = validationResult(req)
if (!errors.isEmpty()) {
return res.status(422).json({ errors: errors.array() })
}
console.log('dref: POST Target\n' + JSON.stringify(req.body, null, 4))
const record = {
target: req.body.target,
script: req.body.script
}
if (typeof req.body.hang !== 'undefined') record.hang = req.body.hang
if (typeof req.body.fastRebind !== 'undefined') record.fastRebind = req.body.fastRebind
if (typeof req.body.args !== 'undefined') record.args = req.body.args
Target.findOneAndUpdate({
router.post('/technology/create', technologyValidator.createValidators(), (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(422).json({errors: errors.mapped()});
}
return technologyService.doesTechnologyExist(req.body.name, req.body.id).then(doesExist => {
if (doesExist) {
res.status(409).json({errors: {latest: {msg: 'Technology already exists'}}});
} else {
technologyService.createTechnology(req.body).then(technology => {
res.status(200).send(technology);
}).catch(error => {
res.status(500).json({errors: {er: {msg: error.message}}});
});
}
}).catch(error => {
res.status(500).json({errors: {er: {msg: error.message}}});
exports.getRecipientdata = (req, res, next) => {
function setAuthorizationStatus(status) {
const authorizationStatus = status;
return authorizationStatus;
}
const errors = validationResult(req);
const id_recipient = req.params.recipientId;
if (!errors.isEmpty()) {
return next(newError(422, errors.array()));
}
Transaction.findAll({
limit: 4,
where: {
id_recipient,
authorization_status: setAuthorizationStatus(1),
},
attributes: [
'amount_money',
'date_time',
'id_recipient',
async (req, res, next) => {
try {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return new Response.BadRequest({ errors: errors.array() }).send(res);
}
const revision = await Revision.findByPk(req.params.revisionId, {
include: [
Revision.associations.author,
Revision.associations.wikitext,
],
});
if (!revision) {
return new Response.ResourceNotFound().send(res);
}
return new Response.Success({
revision: {
id: revision.id,
changedLength: revision.changedLength,
return (req, res, next) => {
logger.debug('req.query', req.query);
logger.debug('req.params', req.params);
logger.debug('req.body', req.body);
const errObjArray = validationResult(req);
if (errObjArray.isEmpty()) {
return next();
}
const errs = errObjArray.array().map((err) => {
logger.error(`${err.location}.${err.param}: ${err.value} - ${err.msg}`);
return new ErrorV3(`${err.param}: ${err.msg}`, 'validation_failed');
});
return res.apiv3Err(errs);
};
}
async (req: Request, res: Response, next: NextFunction) => {
const billService = new BillService();
const userService = new UserService();
const validationErrors = validationResult(req);
const accountBill: string = req.params.accountBill;
if (!validationErrors.isEmpty()) {
const err: IResponseError = {
success: false,
code: HttpStatus.BAD_REQUEST,
error: validationErrors.array()
};
return next(err);
}
try {
const user: User = await userService.getById(req.user.id);
const bills = await billService.getUsersByAccountBill(
accountBill,
user
async (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
const { email, password } = req.body;
try {
let user = await User.findOne({ email });
if (!user) {
return res
.status(400)
.json({ errors: [{ msg: 'Invalid Credentials' }] });
}
const isMatch = await bcrypt.compare(password, user.password);
async (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
const {
school,
degree,
fieldofstudy,
from,
to,
current,
description
} = req.body;
const newEdu = {
school,
module.exports = function (req, res, next) {
const errors = validationResult (req);
if (errors.isEmpty ())
return next ();
return next (new HttpError (400, 'validation_failed', 'The request validation failed.', {validation: errors.mapped ()}));
};