Open broofa opened 7 months ago
Problem: We'd like to require certain merge paths to always be defined.
For example: If attempting to merge objects a and b, and b.properties is defined, we'd like to throw if `a.properties is not defined.
a
b
b.properties
Current solution: Per this comment, this is accomplished with a customMerge function that looks something like this:
// merge options customMerge(key) { if (key === 'properties') { return function (a, b) { if (!a) throw Error('properties is not defined'); } } }
This is awkward. It's just weird that the test for property name and value(s) is split across two different functions.
Proposed solution: Extend the customMerge() method signature to take key, object_a, object_b. This would allow the code above to be simplified:
customMerge()
key, object_a, object_b
// merge options customMerge(key, a, b) { if (key === 'properties' && !a) { throw Error('properties is not defined'); } }
Problem: We'd like to require certain merge paths to always be defined.
For example: If attempting to merge objects
a
andb
, andb.properties
is defined, we'd like to throw if `a.properties is not defined.Current solution: Per this comment, this is accomplished with a customMerge function that looks something like this:
This is awkward. It's just weird that the test for property name and value(s) is split across two different functions.
Proposed solution: Extend the
customMerge()
method signature to takekey, object_a, object_b
. This would allow the code above to be simplified: