Files: 6cee7ba74d78d7a794627b917b1eef6f217416ff / poll / sync / isPoll.js
536 bytesRaw
1 | const Validator = require('is-my-json-valid') |
2 | const schema = require('../schema/poll') |
3 | const validator = Validator(schema, {verbose: true}) |
4 | const getMsgContent = require('../../lib/getMsgContent') |
5 | |
6 | // server is not used here. Closure pattern is just for consistency of use with other functions. |
7 | module.exports = function (server) { |
8 | return function isPoll (obj) { |
9 | const result = validator(getMsgContent(obj)) |
10 | |
11 | // exposes error messages provided by is-my-json-valid |
12 | isPoll.errors = validator.errors |
13 | |
14 | return result |
15 | } |
16 | } |
17 |
Built with git-ssb-web