git ssb

1+

mixmix / scuttle-book



Tree: e9238520ce96e4b6ad803bf181a65eb9d888feb4

Files: e9238520ce96e4b6ad803bf181a65eb9d888feb4 / sync / isBook.js

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

Built with git-ssb-web