git ssb

0+

Piet / ssb-loomio



Tree: dbfe7b74a3adb5a6f94f01cd9a3f8fd4d696bd93

Files: dbfe7b74a3adb5a6f94f01cd9a3f8fd4d696bd93 / sync / isPoll.js

604 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
23
24

Built with git-ssb-web