Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f9c699b

Browse files
committed
Ref #563 - return unique validation errors (prevents multiple validators from returning "this field is required", etc)
1 parent 9f4c72a commit f9c699b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎src/fields/abstractField.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { get as objGet, forEach, isFunction, isString, isArray, debounce, uniqueId } from "lodash";
1+
import { get as objGet, forEach, isFunction, isString, isArray, debounce, uniqueId,uniqasarrayUniq } from "lodash";
22
import validators from "../utils/validators";
33
import { slugifyFormID } from "../utils/schema";
44

@@ -107,9 +107,9 @@ export default {
107107
});
108108
}
109109

110-
let handleErrors = errors => {
110+
let handleErrors = (errors) => {
111111
let fieldErrors = [];
112-
forEach(errors, err => {
112+
forEach(arrayUniq(errors), err => {
113113
if (isArray(err) && err.length > 0) {
114114
fieldErrors = fieldErrors.concat(err);
115115
} else if (isString(err)) {
@@ -139,7 +139,7 @@ export default {
139139
if (!isFunction(this.debouncedValidateFunc)) {
140140
this.debouncedValidateFunc = debounce(
141141
this.validate.bind(this),
142-
objGet(this, "$parent.options.validateDebounceTime", 500)
142+
objGet(this.schema, "validateDebounceTime",objGet(this.formOptions,"validateDebounceTime", 500))
143143
);
144144
}
145145
this.debouncedValidateFunc();
@@ -162,8 +162,8 @@ export default {
162162
this.schema.onChanged.call(this, this.model, newValue, oldValue, this.schema);
163163
}
164164

165-
if (objGet(this.$parent, "options.validateAfterChanged", false) === true) {
166-
if (objGet(this.$parent, "options.validateDebounceTime", 0) > 0) {
165+
if (objGet(this.formOptions, "validateAfterChanged", false) === true) {
166+
if (objGet(this.schema, "validateDebounceTime",objGet(this.formOptions,"validateDebounceTime", 0)) > 0) {
167167
this.debouncedValidate();
168168
} else {
169169
this.validate();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /