Skip to content

Commit

Permalink
Merge pull request #573 from zoul0813/feature/563-unique-validation-e…
Browse files Browse the repository at this point in the history
…rrors

Ref #563 - return unique validation errors
  • Loading branch information
zoul0813 authored Dec 22, 2018
2 parents 9f4c72a + f9c699b commit fa934e8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/fields/abstractField.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get as objGet, forEach, isFunction, isString, isArray, debounce, uniqueId } from "lodash";
import { get as objGet, forEach, isFunction, isString, isArray, debounce, uniqueId, uniq as arrayUniq } from "lodash";
import validators from "../utils/validators";
import { slugifyFormID } from "../utils/schema";

Expand Down Expand Up @@ -107,9 +107,9 @@ export default {
});
}

let handleErrors = errors => {
let handleErrors = (errors) => {
let fieldErrors = [];
forEach(errors, err => {
forEach(arrayUniq(errors), err => {
if (isArray(err) && err.length > 0) {
fieldErrors = fieldErrors.concat(err);
} else if (isString(err)) {
Expand Down Expand Up @@ -139,7 +139,7 @@ export default {
if (!isFunction(this.debouncedValidateFunc)) {
this.debouncedValidateFunc = debounce(
this.validate.bind(this),
objGet(this, "$parent.options.validateDebounceTime", 500)
objGet(this.schema, "validateDebounceTime", objGet(this.formOptions, "validateDebounceTime", 500))
);
}
this.debouncedValidateFunc();
Expand All @@ -162,8 +162,8 @@ export default {
this.schema.onChanged.call(this, this.model, newValue, oldValue, this.schema);
}

if (objGet(this.$parent, "options.validateAfterChanged", false) === true) {
if (objGet(this.$parent, "options.validateDebounceTime", 0) > 0) {
if (objGet(this.formOptions, "validateAfterChanged", false) === true) {
if (objGet(this.schema, "validateDebounceTime", objGet(this.formOptions, "validateDebounceTime", 0)) > 0) {
this.debouncedValidate();
} else {
this.validate();
Expand Down

0 comments on commit fa934e8

Please sign in to comment.