Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit e23adb9

Browse files
committed
add valid property in each field response object
1 parent 0df7485 commit e23adb9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/jquery.formvalidator.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,22 @@
128128
//validate the field
129129
var resp = validateField(field, pendingValidations[field]);
130130
if(!resp.valid) {
131-
fields[field] = { field: resp.field, messages: resp.messages};
131+
fields[field] = { field: resp.field, messages: resp.messages, valid: !resp.messages.length };
132132
}
133133
}
134134
if(clearAfter) { clearPendingValidations(); }
135135
return { valid: !Object.keys(fields).length, fields: fields };
136136
};
137137

138+
/*fields object looks like:
139+
* var fields = {
140+
* username: {
141+
*
142+
*
143+
*/
144+
var getAllErrors = function(fieldsObj) {
145+
};
146+
138147
//object that we store all the validations in - this object is not exposed publically
139148
//validation methods are passed in three things: value, argument(s), object
140149
//value = the value of the field

test/spec/formvalidatorSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ describe("jQuery Form Validator", function() {
218218
expect(validationResp.valid).toEqual(false);
219219
expect(validationResp.fields["email"].messages.length).toEqual(1);
220220
expect(validationResp.fields["email"].messages[0]).toEqual("Field email is required");
221+
expect(validationResp.fields["email"].valid).toEqual(false);
221222
});
222223

223224
it("can add validations for same field multiple times", function() {
@@ -240,6 +241,7 @@ describe("jQuery Form Validator", function() {
240241
validationResp = validationTest.runValidations();
241242
expect(validationResp.valid).toEqual(false);
242243
expect(validationResp.fields["username"].messages.length).toEqual(1);
244+
expect(validationResp.fields["username"].valid).toEqual(false);
243245

244246
});
245247

0 commit comments

Comments
 (0)