Skip to content

Commit

Permalink
If the field has its own isValid method, call it.
Browse files Browse the repository at this point in the history
Fixes #153.
  • Loading branch information
ljharb committed Jan 7, 2015
1 parent d24ab30 commit fbb4e5d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ exports.create = function (fields, opts) {
b.isValid = function () {
var form = this;
return Object.keys(form.fields).every(function (k) {
return form.fields[k].error === null || typeof form.fields[k].error === 'undefined';
var field = form.fields[k];
if (is.fn(field.isValid)) { return field.isValid(); }
return field.error === null || typeof field.error === 'undefined';
});
};
return b;
Expand Down

0 comments on commit fbb4e5d

Please sign in to comment.