Files: 028237b4b26db208a93b7399ed9575c6608b1999 / position / sync / isPosition.js
744 bytesRaw
1 | const validator = require('is-my-json-valid') |
2 | const schema = require('../schema/position') |
3 | const isPositionContent = validator(schema, {verbose: true}) |
4 | const getMsgContent = require('../../lib/getMsgContent') |
5 | const { CHOOSE_ONE } = require('../../types') |
6 | |
7 | const isChooseOnePosition = require('./isChooseOnePosition')() |
8 | |
9 | // server is not used here. Closure pattern is just for consistency of use with other functions. |
10 | module.exports = function (server) { |
11 | function isPosition (obj) { |
12 | const result = isPositionContent(getMsgContent(obj)) |
13 | |
14 | // exposes error messages provided by is-my-json-valid |
15 | isPosition.errors = isPositionContent.errors |
16 | |
17 | return result |
18 | } |
19 | |
20 | isPosition[CHOOSE_ONE] = isChooseOnePosition |
21 | |
22 | return isPosition |
23 | } |
24 |
Built with git-ssb-web