git ssb

0+

Piet / ssb-loomio



Tree: e602c7f5b93b901ece225fec5f2fc495eeaed73d

Files: e602c7f5b93b901ece225fec5f2fc495eeaed73d / schema / positionTypes / chooseOne.js

685 bytesRaw
1const Validate = require('is-my-json-valid')
2
3const typeString = 'chooseOne'
4const typeStringPattern = `^${typeString}$`
5const typeStringRegex = new RegExp(typeStringPattern)
6
7function isValidTypeString (string) {
8 return typeStringRegex.test(string)
9}
10
11function create ({choice, reason}) {
12 return {
13 choice,
14 type: typeString,
15 reason
16 }
17}
18
19var schema = {
20 type: 'object',
21 required: ['type', 'choice'],
22 properties: {
23 type: {
24 type: 'string',
25 pattern: typeStringPattern
26 },
27 choice: {
28 type: 'string'
29 }
30 }
31}
32
33const validate = Validate(schema, { verbose: true })
34
35module.exports = {
36 isValidTypeString,
37 schema,
38 validate,
39 create
40}
41

Built with git-ssb-web