Skip to content

Commit

Permalink
Add validator context to custom_validators so that for example the th…
Browse files Browse the repository at this point in the history
…is.translate method is usable within custom validators
  • Loading branch information
benurb committed Apr 28, 2015
1 parent 8a87aad commit 0cb63eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ JSONEditor.Validator = Class.extend({
return this._validateSchema(this.schema, value);
},
_validateSchema: function(schema,value,path) {
var self = this;
var errors = [];
var valid, i, j;
var stringified = JSON.stringify(value);
Expand Down Expand Up @@ -509,7 +510,7 @@ JSONEditor.Validator = Class.extend({

// Custom type validation
$each(JSONEditor.defaults.custom_validators,function(i,validator) {
errors = errors.concat(validator(schema,value,path));
errors = errors.concat(validator.call(self,schema,value,path));
});

return errors;
Expand Down

0 comments on commit 0cb63eb

Please sign in to comment.