Skip to content

Commit 27fb7c9

Browse files
add and ; fix checking
1 parent 505b171 commit 27fb7c9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lib/node-rules.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@
100100
switch (key) {
101101
case '$field': return [true, dig(facts, value.$field)];
102102

103+
case '$clone':
104+
var [isValid, value] = compileValue(facts, value[key]);
105+
if (!isValid)
106+
throw new Error('Invalid property for clone: ' + key);
107+
return [true, _.clone(value)];
108+
case '$cloneDeep':
109+
var [isValid, value] = compileValue(facts, value[key]);
110+
if (!isValid)
111+
throw new Error('Invalid property for deep clone: ' + key);
112+
return [true, cloneDeep(value)];
113+
103114
case '$minOf':
104115
case '$maxOf':
105116
case '$sumOf':
@@ -199,7 +210,7 @@
199210
}
200211
}
201212

202-
// FIXME? should this be isValid?
213+
// FIXME? should this be `isValid?`
203214
return value !== undefined ? fact == value : checkConditions(fact, subConds, true);
204215
});
205216
};
@@ -213,7 +224,7 @@
213224
_.each(_.isArray(operations) ? operations : [operations], function (subOps, i) {
214225
if (subOps.$each) {
215226
return _.each(fact, function (subFact, subKey) {
216-
if (!subOps.$where || checkConditions(subFact, subOps.$where, true))
227+
if (!subOps.$where || checkConditions({ item: subFact }, { item: subOps.$where }, true))
217228
updateFact(facts, _.isString(subKey) ? key + '.' + subKey : key + '[' + subKey + ']', subOps.$each);
218229
});
219230
}

0 commit comments

Comments
 (0)