const shape = require('checkshape');
const s = shape({
user_id: (userId) => userExists(userId),
name: (name, {user_id}) => findUserByName(name).then((user) => user.id === user_id)
})
s.check(data).then(({result, errors}) => {})
aregee / checkshape Goto Github PK
View Code? Open in Web Editor NEWcheck shapes of JS objects in an async manner