File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ async function validateRule(
33
33
messageVariables ?: Record < string , string > ,
34
34
) : Promise < string [ ] > {
35
35
const cloneRule = { ...rule } ;
36
+
37
+ // Bug of `async-validator`
38
+ // https://github.com/react-component/field-form/issues/316
39
+ // https://github.com/react-component/field-form/issues/313
40
+ delete ( cloneRule as any ) . ruleIndex ;
41
+
36
42
// We should special handle array validate
37
43
let subRuleField : RuleObject = null ;
38
44
if ( cloneRule && cloneRule . type === 'array' && cloneRule . defaultField ) {
@@ -218,13 +224,13 @@ export function validateRules(
218
224
}
219
225
220
226
async function finishOnAllFailed ( rulePromises : Promise < RuleError > [ ] ) : Promise < RuleError [ ] > {
221
- return Promise . all ( rulePromises ) . then ( ( errorsList : RuleError [ ] ) :
222
- | RuleError [ ]
223
- | Promise < RuleError [ ] > => {
224
- const errors : RuleError [ ] = [ ] . concat ( ...errorsList ) ;
227
+ return Promise . all ( rulePromises ) . then (
228
+ ( errorsList : RuleError [ ] ) : RuleError [ ] | Promise < RuleError [ ] > => {
229
+ const errors : RuleError [ ] = [ ] . concat ( ...errorsList ) ;
225
230
226
- return errors ;
227
- } ) ;
231
+ return errors ;
232
+ } ,
233
+ ) ;
228
234
}
229
235
230
236
async function finishOnFirstFailed ( rulePromises : Promise < RuleError > [ ] ) : Promise < RuleError [ ] > {
Original file line number Diff line number Diff line change @@ -726,5 +726,17 @@ describe('Form.Validate', () => {
726
726
const values = await form . validateFields ( [ 'username' ] ) ;
727
727
expect ( values . username . do ) . toBe ( '' ) ;
728
728
} ) ;
729
+
730
+ it ( 'not trigger validator' , async ( ) => {
731
+ const wrapper = mount (
732
+ < div >
733
+ < Form >
734
+ < InfoField name = "user" rules = { [ { required : true } ] } />
735
+ </ Form >
736
+ </ div > ,
737
+ ) ;
738
+ await changeValue ( getField ( wrapper , 0 ) , [ 'light' ] ) ;
739
+ matchError ( wrapper , false ) ;
740
+ } ) ;
729
741
} ) ;
730
742
/* eslint-enable no-template-curly-in-string */
You can’t perform that action at this time.
0 commit comments