git ssb

0+

Piet / ssb-loomio



Tree: dbfe7b74a3adb5a6f94f01cd9a3f8fd4d696bd93

Files: dbfe7b74a3adb5a6f94f01cd9a3f8fd4d696bd93 / schema / pollTypes / chooseOne.js

671 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({choices}) {
12 return {
13 choices,
14 type: typeString,
15 }
16}
17
18var schema = {
19 type: 'object',
20 required: ['type', 'choices'],
21 properties: {
22 type: {
23 type: 'string',
24 pattern: typeStringPattern
25 },
26 choices: {
27 type: 'array',
28 }
29 }
30}
31
32const validate = Validate(schema, { verbose: true })
33
34module.exports = {
35 isValidTypeString,
36 schema,
37 validate,
38 create
39}
40

Built with git-ssb-web