Files: fd35bcd5410f1f010361327040a3f0a52b4bddd9 / sync / isPoll.js
604 bytesRaw
1 | const validator = require('is-my-json-valid') |
2 | const schema = require('../schema/poll') |
3 | const isPollContent = validator(schema, {verbose: true}) |
4 | |
5 | // server is not used here. Closure pattern is just for consistency of use with other functions. |
6 | module.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 | |
17 | function 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