base-config-schema
Version:
Schema for the base-config plugin, used for normalizing config values before passing them to config.process().
29 lines (22 loc) • 605 B
JavaScript
;
var utils = require('../utils');
module.exports = function(app, options) {
return function(val, key, config, schema) {
if (!val || utils.isEmpty(val)) return null;
if (typeof val === 'string') {
val = val.split(',').filter(Boolean);
}
if (Array.isArray(val)) {
val = { list: val };
}
if (utils.isObject(val) && typeof val.list === 'string') {
val.list = val.list.split(',').filter(Boolean);
}
if (!val.list) {
val.list = [];
return val;
}
val.list = utils.unique(utils.flatten(val.list));
return val;
};
};