Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/routes/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ helper.validate = (someObject, someDefinition, callback) => {
Joi.validate(someObject, someDefinition, { abortEarly: false }, (err, sanitisedObject) => {
if (err) {
return callback({ // eslint-disable-line standard/no-callback-literal
status: '403',
code: 'EFORBIDDEN',
status: '400',
code: 'EBADREQUEST',
title: 'Param validation failed',
detail: err.details
})
Expand All @@ -28,17 +28,17 @@ helper.validate = (someObject, someDefinition, callback) => {
helper.checkForBody = (request, callback) => {
if (!request.params.data) {
return callback({ // eslint-disable-line standard/no-callback-literal
status: '403',
code: 'EFORBIDDEN',
status: '400',
code: 'EBADREQUEST',
title: 'Request validation failed',
detail: 'Missing "data" - have you sent the right http headers?'
})
}
// data can be {} or [] both of which are typeof === 'object'
if (typeof request.params.data !== 'object') {
return callback({ // eslint-disable-line standard/no-callback-literal
status: '403',
code: 'EFORBIDDEN',
status: '400',
code: 'EBADREQUEST',
title: 'Request validation failed',
detail: '"data" must be an object - have you sent the right http headers?'
})
Expand Down