git ssb

0+

Piet / ssb-loomio



Commit c11e72244cf922e07314cd51643afc5722c6225a

Merge branch 'master' of github.com:ssbc/scuttle-poll into poll-refactor

mix irving committed on 3/1/2018, 12:54:16 AM
Parent: 3c2e645f7b5dccfbc0afd288ee28c0465837a6ec
Parent: 8818456f68cdf8d623639cc4bc69b81a61f90869

Files changed

schema/position.jschanged
schema/positionTypes/chooseOne.jsdeleted
schema/positionDetails/chooseOne.jsadded
schema/position.jsView
@@ -4,9 +4,9 @@
44 //
55 // well for a chooseOne:
66 // {
77 // pollId: msgId,
8-// choice: 'apple', //what if this is a key? Or a key and index number? I wonder if this is an argument for making each choice a separate message?
8 +// choice: 0, // index of the choice
99 // reason: "I don't like doctorbs",
1010 // }
1111 // When do the various validations happen?
1212 // - when we're counting votes. We need to check it's a valid position for the type of poll
schema/positionTypes/chooseOne.jsView
@@ -1,40 +1,0 @@
1-const Validate = require('is-my-json-valid')
2-
3-const typeString = 'chooseOne'
4-const typeStringPattern = `^${typeString}$`
5-const typeStringRegex = new RegExp(typeStringPattern)
6-
7-function isValidTypeString (string) {
8- return typeStringRegex.test(string)
9-}
10-
11-function create ({choice, reason}) {
12- return {
13- choice,
14- type: typeString,
15- reason
16- }
17-}
18-
19-var 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-
33-const validate = Validate(schema, { verbose: true })
34-
35-module.exports = {
36- isValidTypeString,
37- schema,
38- validate,
39- create
40-}
schema/positionDetails/chooseOne.jsView
@@ -1,0 +1,41 @@
1 +const Validate = require('is-my-json-valid')
2 +
3 +const typeString = 'chooseOne'
4 +const typeStringPattern = `^${typeString}$`
5 +const typeStringRegex = new RegExp(typeStringPattern)
6 +
7 +function isValidTypeString (string) {
8 + return typeStringRegex.test(string)
9 +}
10 +
11 +function create ({choice, reason}) {
12 + return {
13 + choice,
14 + type: typeString,
15 + reason
16 + }
17 +}
18 +
19 +var schema = {
20 + type: 'object',
21 + required: ['type', 'choice'],
22 + properties: {
23 + type: {
24 + type: 'string',
25 + pattern: typeStringPattern
26 + },
27 + choice: {
28 + type: 'integer',
29 + minimum: 0
30 + }
31 + }
32 +}
33 +
34 +const validate = Validate(schema, { verbose: true })
35 +
36 +module.exports = {
37 + isValidTypeString,
38 + schema,
39 + validate,
40 + create
41 +}

Built with git-ssb-web