git ssb

0+

Piet / ssb-loomio



Tree: e602c7f5b93b901ece225fec5f2fc495eeaed73d

Files: e602c7f5b93b901ece225fec5f2fc495eeaed73d / sync / isPoll.js

602 bytesRaw
1const validator = require('is-my-json-valid')
2const schema = require('../schema/poll')
3const isPollContent = validator(schema, {verbose: true})
4
5// server is not used here. Closure pattern is just for consistency of use with other functions.
6module.exports = function (server) {
7 return function isPoll (obj) {
8 const result = isPollContent(getMsgContent(obj))
9
10 // exposes error messages provided by is-my-json-valid
11 isPoll.errors = isPollContent.errors
12
13 return result
14 }
15}
16
17function getMsgContent (obj) {
18 if (obj.value && obj.value.content) return obj.value.content
19
20 return obj
21}
22

Built with git-ssb-web