forked from ekelen/tarot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_validate.js
29 lines (24 loc) · 1.16 KB
/
data_validate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var jsonfile = require('jsonfile')
var path = require('path')
var assert = require('assert')
import _ from 'lodash'
const root = __dirname + '/data'
function validate(file) {
const rOrig = jsonfile.readFileSync(file)
const { cards } = rOrig
assert(cards.length === 78, 'incorrect number of cards.')
cards.forEach((c, i) => {
assert(c.name && c.name.length, 'Has no name for ' + c.name_short)
assert(c.name_short && c.name_short.length === 4, 'Bad short name for ' + c.name)
assert(c.desc && c.desc.length, 'Bad desc for ' + c.name_short)
assert(_.has(c, 'value_int') && !_.isNaN(c.value_int), 'Bad int val for ' + c.name_short)
assert(c.value && c.value.length, 'Bad val for ' + c.name_short)
assert(c.meaning_up && c.meaning_up.length, 'Bad meaning_up for ' + c.name_short)
assert((c.meaning_rev && c.meaning_rev.length) || c.name_short === 'cu02', 'Bad meaning_rev for ' + c.name_short)
assert(c.type && ["major", "minor"].includes(c.type), 'Bad type for ' + c.name_short)
})
cards.filter(c => c.type === 'minor').forEach((c, i) => {
assert(c.suit && c.suit.length, 'Has no suit for ' + c.name_short)
})
console.log('All good.')
}