Moves to next challenges

This commit is contained in:
Berkeley Martinez
2016-06-01 15:52:08 -07:00
parent 515051d817
commit cc8b608cb9
16 changed files with 327 additions and 546 deletions

View File

@@ -1,4 +1,7 @@
import validator from 'express-validator';
import { isPoly } from '../../common/utils/polyvinyl';
const isObject = val => !!val && typeof val === 'object';
export default function() {
return validator({
@@ -11,6 +14,17 @@ export default function() {
},
isNumber(value) {
return typeof value === 'number';
},
isFiles(value) {
if (!isObject(value)) {
return false;
}
const keys = Object.keys(value);
return !!keys.length &&
// every key is a file
keys.every(key => isObject(value[key])) &&
// every file has contents
keys.map(key => value[key]).every(file => isPoly(file));
}
}
});