Skip to content

Commit 0cb63eb

Browse files
committed
Add validator context to custom_validators so that for example the this.translate method is usable within custom validators
1 parent 8a87aad commit 0cb63eb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/validator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ JSONEditor.Validator = Class.extend({
99
return this._validateSchema(this.schema, value);
1010
},
1111
_validateSchema: function(schema,value,path) {
12+
var self = this;
1213
var errors = [];
1314
var valid, i, j;
1415
var stringified = JSON.stringify(value);
@@ -509,7 +510,7 @@ JSONEditor.Validator = Class.extend({
509510

510511
// Custom type validation
511512
$each(JSONEditor.defaults.custom_validators,function(i,validator) {
512-
errors = errors.concat(validator(schema,value,path));
513+
errors = errors.concat(validator.call(self,schema,value,path));
513514
});
514515

515516
return errors;

0 commit comments

Comments
 (0)