Skip to content

Commit df334c3

Browse files
committed
Passing control name to validate:(value, name)
When we use one validate function across all editable controls, passing a `name` should validating individual fields.
1 parent f32802f commit df334c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/editable-form/editable-form.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
201201

202202
//validation: if validate returns string or truthy value - means error
203203
//if returns object like {newValue: '...'} => submitted value is reassigned to it
204-
var error = this.validate(newValue);
204+
var error = this.validate(newValue, this.options.name);
205205
if ($.type(error) === 'object' && error.newValue !== undefined) {
206206
newValue = error.newValue;
207207
this.input.value2input(newValue);
@@ -341,12 +341,12 @@ Editableform is linked with one of input types, e.g. 'text', 'select' etc.
341341
}
342342
},
343343

344-
validate: function (value) {
344+
validate: function (value, name) {
345345
if (value === undefined) {
346346
value = this.value;
347347
}
348348
if (typeof this.options.validate === 'function') {
349-
return this.options.validate.call(this.options.scope, value);
349+
return this.options.validate.call(this.options.scope, value, name);
350350
}
351351
},
352352

0 commit comments

Comments
 (0)