Skip to content

Commit

Permalink
[Fix] validatePastFirstError: actually respect the option
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Mar 13, 2024
1 parent 9f118a8 commit 45cfb3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ exports.string = function (options) {
if (!b.error) {
v(form, b, function (v_err) {
b.error = v_err ? String(v_err) : null;
asyncCallback(null);
asyncCallback(b.error);
});
} else {
asyncCallback(null);
asyncCallback(b.error);
}
}, function (err) {
callback(err, b);
Expand Down
4 changes: 2 additions & 2 deletions test/test-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test('bind with missing field in data keeps field in form', function (t) {
});

test('validate', function (t) {
t.plan(11);
t.plan(12);
var form = forms.create({
field1: forms.fields.string(),
field2: forms.fields.string({
Expand Down Expand Up @@ -163,7 +163,7 @@ test('validate invalid data', function (t) {
callback('validation error 2');
}]
})
});
}, { validatePastFirstError: true });
formObject.bind({ field1: '1', field2: '2' }).validate(function (err, f) {
t.equal(f.isValid(), false);
t.equal(
Expand Down
12 changes: 4 additions & 8 deletions test/test-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var testWrap = function (tag) {
callback('validation error after field');
}]
})
});
}, { validatePastFirstError: true });
formObject.bind({ field_name: 'val', field_name_error_after: 'foo' }).validate(function (err, f) {
t.equal(
f.toHTML(forms.render[tag]),
Expand Down Expand Up @@ -124,7 +124,7 @@ var testWrap = function (tag) {
callback('validation error after field');
}]
})
});
}, { validatePastFirstError: true });
f2.bind({ field_name: 'val', field_name_error_after: 'foo' }).validate(function (err, f) {
t.equal(
f.toHTML(forms.render[tag]),
Expand All @@ -148,8 +148,6 @@ var testWrap = function (tag) {
'<p class="error_msg">validation error after field</p>'
);
});

t.end();
});

test(tag + ' multipleCheckbox', function (t) {
Expand Down Expand Up @@ -295,7 +293,7 @@ test('table bound error', function (t) {
callback('validation error after field');
}]
})
});
}, { validatePastFirstError: true });
formObject.bind({ field_name: 'val', field_name_error_after: 'foo' }).validate(function (err, f) {
t.equal(
f.toHTML(forms.render.table),
Expand Down Expand Up @@ -331,7 +329,7 @@ test('table bound error', function (t) {
callback('validation error after field');
}]
})
});
}, { validatePastFirstError: true });
f2.bind({ field_name: 'val', field_name_error_after: 'foo' }).validate(function (err, f) {
t.equal(
f.toHTML(forms.render.table),
Expand All @@ -358,6 +356,4 @@ test('table bound error', function (t) {
'<p class="error_msg">validation error after field</p>'
);
});

t.end();
});

0 comments on commit 45cfb3f

Please sign in to comment.