git ssb

0+

Piet / ssb-loomio



Tree: 4d462b129a9f5195f3ae4e70fcf2bccea36ebbb4

Files: 4d462b129a9f5195f3ae4e70fcf2bccea36ebbb4 / poll / sync / isPoll.js

750 bytesRaw
1const Validator = require('is-my-json-valid')
2const schema = require('../schema/poll')
3const validator = Validator(schema, {verbose: true})
4const getMsgContent = require('../../lib/getMsgContent')
5const { CHOOSE_ONE } = require('../../types')
6
7const isChooseOnePoll = require('./isChooseOnePoll')()
8
9// server is not used here. Closure pattern is just for consistency of use with other functions.
10module.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