Skip to content

Commit

Permalink
Add validateDebounceTime formOption to fix #309
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Oct 11, 2017
1 parent dfe823c commit 20bbd59
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/fields/abstractField.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get as objGet, each, isFunction, isString, isArray } from "lodash";
import { get as objGet, each, isFunction, isString, isArray, debounce } from "lodash";
import validators from "../utils/validators";
import { slugifyFormID } from "../utils/schema";

Expand Down Expand Up @@ -64,8 +64,15 @@ export default {
this.schema.onChanged.call(this, this.model, newValue, oldValue, this.schema);
}

if (this.$parent.options && this.$parent.options.validateAfterChanged === true){
this.validate();
if (this.$parent.options && this.$parent.options.validateAfterChanged === true) {
if (this.$parent.options.validateDebounceTime > 0) {
if (!this.debouncedValidate)
this.debouncedValidate = debounce(this.validate.bind(this), this.$parent.options.validateDebounceTime);

this.debouncedValidate();
} else {
this.validate();
}
}
}
}
Expand Down

0 comments on commit 20bbd59

Please sign in to comment.