Changed Collection documents to documentStructure and other WIP stuff

This commit is contained in:
Jori Lallo
2017-06-04 14:40:27 -07:00
parent 9631e58e65
commit c229369efd
6 changed files with 131 additions and 192 deletions

View File

@ -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();
};
}