@@ -8,8 +8,8 @@ import omit from '../utils/omit';
8
8
9
9
import actions from '../actions' ;
10
10
import getValidity from '../utils/get-validity' ;
11
- import invertValidity from '../utils/invert-validity' ;
12
11
import invertValidators from '../utils/invert-validators' ;
12
+ import isValidityInvalid from '../utils/is-validity-invalid' ;
13
13
import getForm from '../utils/get-form' ;
14
14
import getModel from '../utils/get-model' ;
15
15
import getField from '../utils/get-field' ;
@@ -148,33 +148,13 @@ function createFormClass(s = defaultStrategy) {
148
148
const validatorsChanged = validators !== this . props . validators
149
149
|| errors !== this . props . errors ;
150
150
151
- let validityChanged = false ;
152
-
153
- const fieldsValidity = mapValues ( validators , ( validator , field ) => {
154
- const nextValue = field
155
- ? s . get ( nextProps . modelValue , field )
156
- : nextProps . modelValue ;
151
+ const errorValidators = validators
152
+ ? merge ( invertValidators ( validators ) , errors )
153
+ : errors ;
157
154
158
- const currentValue = field
159
- ? s . get ( modelValue , field )
160
- : modelValue ;
161
-
162
- const currentValidity = getField ( formValue , field ) . validity ;
163
-
164
- if ( ( ! initial && ! validatorsChanged ) && ( nextValue === currentValue ) ) {
165
- return currentValidity ;
166
- }
167
-
168
- const fieldValidity = getValidity ( validator , nextValue ) ;
169
-
170
- if ( ! shallowEqual ( fieldValidity , currentValidity ) ) {
171
- validityChanged = true ;
172
- }
173
-
174
- return fieldValidity ;
175
- } ) ;
155
+ let validityChanged = false ;
176
156
177
- const fieldsErrorsValidity = mapValues ( errors , ( errorValidator , field ) => {
157
+ const fieldsErrors = mapValues ( errorValidators , ( errorValidator , field ) => {
178
158
const nextValue = field
179
159
? s . get ( nextProps . modelValue , field )
180
160
: nextProps . modelValue ;
@@ -198,14 +178,11 @@ function createFormClass(s = defaultStrategy) {
198
178
return fieldErrors ;
199
179
} ) ;
200
180
201
- const fieldsErrors = merge (
202
- invertValidity ( fieldsValidity ) ,
203
- fieldsErrorsValidity
204
- ) ;
205
-
206
181
// Compute form-level validity
207
- if ( ! fieldsValidity . hasOwnProperty ( '' ) && ! fieldsErrorsValidity . hasOwnProperty ( '' ) ) {
182
+ if ( ! fieldsErrors . hasOwnProperty ( '' ) ) {
208
183
fieldsErrors [ '' ] = false ;
184
+ validityChanged = validityChanged
185
+ || isValidityInvalid ( formValue . $form . errors ) ;
209
186
}
210
187
211
188
if ( validityChanged ) {
0 commit comments