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