improve config saving; fix pairing bug

This commit is contained in:
Josh Harvey 2017-05-07 15:29:18 +03:00
parent 67e12b19cb
commit f3f46f7b5b
4 changed files with 81 additions and 9 deletions

View file

@ -3,6 +3,7 @@ const _ = require('lodash/fp')
const configManager = require('./config-manager')
const machines = require('./admin/machines')
const schema = require('../lamassu-schema.json')
const logger = require('./logger')
function allScopes (cryptoScopes, machineScopes) {
const scopes = []
@ -47,7 +48,9 @@ function satisfiesRequire (config, cryptos, machineList, field, refFields) {
const isBlank = _.isNil(configManager.scopedValue(scope[0], scope[1], fieldCode, config))
const isRequired = refFields.length === 0 || isEnabled()
return isRequired ? !isBlank : true
const isValid = isRequired ? !isBlank : true
return isValid
})
}
@ -148,6 +151,7 @@ function validate (config) {
.then(() => validateRequires(config))
.then(arr => {
if (arr.length === 0) return config
logger.error('Invalid configuration: %j', arr)
throw new Error('Invalid configuration')
})
}