1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1× 7× 14× 26× 18× 26× 20× 6× | export default function validateSometimes(validators, condition) { return validators.map(function(validator) { return function(key, newValue, oldValue, changes, content) { let thisValue = { get(property) { return changes[property] || content[property]; } }; if (condition.call(thisValue, changes, content)) { return validator(key, newValue, oldValue, changes, content); } return true; }; }); } |