Changed Collection documents to documentStructure and other WIP stuff
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
// @flow
|
||||
import apiError from '../../errors';
|
||||
import validator from 'validator';
|
||||
|
||||
@ -9,18 +10,24 @@ export default function validation() {
|
||||
}
|
||||
};
|
||||
|
||||
ctx.assertEmail = function assertEmail(value, message) {
|
||||
ctx.assertEmail = (value, message) => {
|
||||
if (!validator.isEmail(value)) {
|
||||
throw apiError(400, 'validation_error', message);
|
||||
}
|
||||
};
|
||||
|
||||
ctx.assertUuid = function assertUuid(value, message) {
|
||||
ctx.assertUuid = (value, message) => {
|
||||
if (!validator.isUUID(value)) {
|
||||
throw apiError(400, 'validation_error', message);
|
||||
}
|
||||
};
|
||||
|
||||
ctx.assertPositiveInteger = (value, message) => {
|
||||
if (!validator.isInt(value, { min: 0 })) {
|
||||
throw apiError(400, 'validation_error', message);
|
||||
}
|
||||
};
|
||||
|
||||
return next();
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user