async-validate
Version:
Asynchronous validation for node and the browser
18 lines (15 loc) • 373 B
JavaScript
module.exports = function() {
/**
* Rule for validating required fields.
*/
this.required = function required() {
if(!this.isRoot()
&& this.rule.required
&& (!this.source.hasOwnProperty(this.field)
|| this.value === undefined)) {
this.raise(
this.reasons.required,
this.messages.required, this.field);
}
}
}