git ssb

0+

Piet / ssb-loomio



Commit 17445d27af23c12c79234b9d06909eb97e55ad50

Merge pull request #8 from ssbc/isChooseOnePoll

add poll.sync.isChooseOnePoll
Piet Geursen authored on 3/6/2018, 2:05:23 AM
GitHub committed on 3/6/2018, 2:05:23 AM
Parent: a3426ae4bc96b37cfb2795e1acb2b31d2b3da6ea
Parent: e91df8e00ca174250db3f719cc4bbf9a3b54b07c

Files changed

package-lock.jsonchanged
package.jsonchanged
poll/schema/chooseOnePoll.jsadded
poll/sync/isPoll.jschanged
poll/sync/isChooseOnePoll.jsadded
package-lock.jsonView
@@ -1,6 +1,6 @@
11 {
2- "name": "ssb-loomio",
2+ "name": "scuttle-poll",
33 "version": "1.0.0",
44 "lockfileVersion": 1,
55 "requires": true,
66 "dependencies": {
@@ -302,8 +302,18 @@
302302 "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz",
303303 "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=",
304304 "dev": true
305305 },
306+ "lodash.clonedeep": {
307+ "version": "4.5.0",
308+ "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz",
309+ "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8="
310+ },
311+ "lodash.merge": {
312+ "version": "4.6.1",
313+ "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
314+ "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ=="
315+ },
306316 "minimatch": {
307317 "version": "3.0.4",
308318 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
309319 "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
package.jsonView
@@ -29,8 +29,9 @@
2929 },
3030 "dependencies": {
3131 "is-my-json-valid": "^2.17.1",
3232 "libnested": "^1.2.1",
33+ "lodash.clonedeep": "^4.5.0",
3334 "ssb-msg-schemas": "^6.3.0",
3435 "ssb-ref": "^2.9.0"
3536 }
3637 }
poll/schema/chooseOnePoll.jsView
@@ -1,0 +1,9 @@
1+const pollSchema = require('./poll')
2+const cloneDeep = require('lodash.clonedeep')
3+
4+const chooseOneSchema = cloneDeep(pollSchema)
5+
6+// collapse the details down to be ONLY chooseOne
7+chooseOneSchema.properties.pollDetails = { $ref: '#/definitions/pollDetails/chooseOne' }
8+
9+module.exports = chooseOneSchema
poll/sync/isPoll.jsView
@@ -1,16 +1,16 @@
1-const validator = require('is-my-json-valid')
1+const Validator = require('is-my-json-valid')
22 const schema = require('../schema/poll')
3-const isPollContent = validator(schema, {verbose: true})
3+const validator = Validator(schema, {verbose: true})
44 const getMsgContent = require('../../lib/getMsgContent')
55
66 // server is not used here. Closure pattern is just for consistency of use with other functions.
77 module.exports = function (server) {
88 return function isPoll (obj) {
9- const result = isPollContent(getMsgContent(obj))
9+ const result = validator(getMsgContent(obj))
1010
1111 // exposes error messages provided by is-my-json-valid
12- isPoll.errors = isPollContent.errors
12+ isPoll.errors = validator.errors
1313
1414 return result
1515 }
1616 }
poll/sync/isChooseOnePoll.jsView
@@ -1,0 +1,16 @@
1+const Validator = require('is-my-json-valid')
2+const schema = require('../schema/chooseOnePoll')
3+const validator = Validator(schema, {verbose: true})
4+const getMsgContent = require('../../lib/getMsgContent')
5+
6+// server is not used here. Closure pattern is just for consistency of use with other functions.
7+module.exports = function (server) {
8+ return function isChooseOnePoll (obj) {
9+ const result = validator(getMsgContent(obj))
10+
11+ // exposes error messages provided by is-my-json-valid
12+ isChooseOnePoll.errors = validator.errors
13+
14+ return result
15+ }
16+}

Built with git-ssb-web