Files: 4d462b129a9f5195f3ae4e70fcf2bccea36ebbb4 / poll / sync / isPoll.js
750 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 | const { CHOOSE_ONE } = require('../../types') |
6 | |
7 | const isChooseOnePoll = require('./isChooseOnePoll')() |
8 | |
9 | // server is not used here. Closure pattern is just for consistency of use with other functions. |
10 | module.exports = function (server) { |
11 | function isPoll (obj) { |
12 | const result = validator(getMsgContent(obj)) |
13 | |
14 | // exposes error messages provided by is-my-json-valid |
15 | isPoll.errors = validator.errors |
16 | |
17 | return result |
18 | } |
19 | |
20 | isPoll[CHOOSE_ONE] = isChooseOnePoll |
21 | // isPoll[DOT] = isDotPoll |
22 | // isPoll[SCORE] = isScorePoll |
23 | |
24 | return isPoll |
25 | } |
26 |
Built with git-ssb-web