Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
return Object.assign({}, value1, value2);
},
validate(value) {
assertIsObject(value);
}
}
});
//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
module.exports = new ObjectSchema({
files: {
required: false,
merge() {
return undefined;
},
validate(value) {
if (value !== undefined) {
// assertIsArrayOfStrings(value);
}
}
},
ignores: {
required: false,
requires: ["files"],
merge() {
function assertIsObject(value, name) {
if (value == null || typeof value !== "object") {
throw new TypeError(`Expected value to be an object.`);
}
}
function assertIsArrayOfStrings(value, name) {
assertIsArray(value, name);
if (value.some(item => typeof item !== "string")) {
throw new TypeError(`Expected array to only contain strings.`);
}
}
const defsSchema = new ObjectSchema({
ruleNamespaces: {
required: false,
merge(value1, value2) {
if (value1 == undefined) {
return value2;
}
if (value2 == undefined) {
return value1;
}
for (const key of Object.keys(value1)) {
if (key in value2 && !Object.is(value2[key], value1[key])) {
throw new Error(`Rule namespace "${key}" is already defined and cannot be redefined.`);
}
}