fix: verify config field existance and content
This commit is contained in:
parent
a8085f3f1d
commit
0c0ca09b4e
5 changed files with 15 additions and 25 deletions
|
|
@ -67,7 +67,7 @@ const CRYPTO_CURRENCIES = [
|
|||
}
|
||||
]
|
||||
|
||||
module.exports = {buildUrl, cryptoDir, blockchainDir, configPath, cryptoCurrencies, getCryptoCurrency, toUnit}
|
||||
module.exports = { buildUrl, cryptoDir, blockchainDir, configPath, cryptoCurrencies, getCryptoCurrency, toUnit, isConfigValid }
|
||||
|
||||
function getCryptoCurrency (cryptoCode) {
|
||||
const cryptoCurrency = _.find(['cryptoCode', cryptoCode], CRYPTO_CURRENCIES)
|
||||
|
|
@ -109,3 +109,8 @@ function toUnit (cryptoAtoms, cryptoCode) {
|
|||
const unitScale = cryptoRec.unitScale
|
||||
return cryptoAtoms.shift(-unitScale)
|
||||
}
|
||||
|
||||
function isConfigValid (config, fields) {
|
||||
const values = _.map(it => _.get(it)(config))(fields)
|
||||
return _.every(it => it || it === 0)(values)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue