| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 2x 2x 1x 1x 1x | import debug from 'debug'
var log = debug('ddf.rule')
// A Rule has actions for a field.
class Rule {
constructor(field, actions) {
this.field = field
this.actions = actions
}
// Execute all actions of this rule.
apply(form) {
log('[Rule]', this, '.apply(', form, ')')
for (var i=0; i<this.actions.length; i++) {
this.actions[i].execute(form.field(this.field))
}
}
}
export {
Rule,
}
|