All files condition.js

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23    3x         5x 5x         5x 5x 5x              
import debug from 'debug'
 
var log = debug('ddf.rule')
 
// Validate if a field has a given value.
class ValueIs {
  constructor(field, value) {
    this.field = field
    this.value = value
  }
 
  // Return true if the field's value is this.value
  validate(form) {
    let valid = form.field(this.field).value == this.value
    log('[Condition]', this, '.validate(', form, ') = ', valid)
    return valid
  }
}
 
export {
  ValueIs,
}