| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 3x 5x 5x 5x 5x 5x | import debug from 'debug'
var log = debug('facond.rule')
/**
* Validate if a field has a given value.
*/
class ValueEq {
/**
* @param field Name of the field to test.
* @param value Value to test.
*/
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 {
ValueEq,
}
|