Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Form.Editor = Form.editors.Base = Backbone.View.extend({
focus: function() {
throw new Error('Not implemented');
},

/**
* Remove focus from the editor
* Extend and override this method
Expand Down Expand Up @@ -133,7 +133,7 @@ Form.Editor = Form.editors.Base = Backbone.View.extend({
if (validators) {
//Run through validators until an error is found
_.every(validators, function(validator) {
error = getValidator(validator)(value, formValues);
error = getValidator(validator)(value, formValues, $el);

return error ? false : true;
});
Expand Down Expand Up @@ -171,11 +171,11 @@ Form.Editor = Form.editors.Base = Backbone.View.extend({
if (_.isRegExp(validator)) {
return validators.regexp({ regexp: validator });
}

//Use a built-in validator if given a string
if (_.isString(validator)) {
if (!validators[validator]) throw new Error('Validator "'+validator+'" not found');

return validators[validator]();
}

Expand All @@ -185,10 +185,10 @@ Form.Editor = Form.editors.Base = Backbone.View.extend({
//Use a customised built-in validator if given an object
if (_.isObject(validator) && validator.type) {
var config = validator;

return validators[config.type](config);
}

//Unkown validator type
throw new Error('Invalid validator: ' + validator);
}
Expand Down