File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
packages/form-state-manager/src Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { Validator } from './validate' ;
2
2
import AnyObject from './any-object' ;
3
3
4
- export type ComposeValidators = ( validators : Validator [ ] ) => ( value : any , allValues : AnyObject ) => Promise < any > | any ;
4
+ export interface WarningObject < T = string | undefined > {
5
+ type : string ;
6
+ error : T ;
7
+ }
8
+
9
+ export type ComposeValidators < T = WarningObject | string | undefined > = (
10
+ validators : Validator [ ]
11
+ ) => ( value : any , allValues : AnyObject ) => Promise < T > | T ;
5
12
6
13
export default ComposeValidators ;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import CreateManagerApi, {
24
24
import AnyObject from '../types/any-object' ;
25
25
import FieldConfig , { IsEqual } from '../types/field-config' ;
26
26
import { Meta } from '../types/use-field' ;
27
+ import { WarningObject } from '../types/compose-validators' ;
27
28
import { formLevelValidator , isPromise } from './validate' ;
28
29
import { FormValidator , FormLevelError , Validator } from '../types/validate' ;
29
30
import findDifference from './find-difference' ;
@@ -323,12 +324,12 @@ const createManagerApi: CreateManagerApi = ({
323
324
} ) ;
324
325
listener . registerValidator ( result as Promise < string | undefined > ) ;
325
326
} else {
326
- if ( result ?. type === 'warning' ) {
327
+ if ( ( result as WarningObject ) ?. type === 'warning' ) {
327
328
setFieldState ( name , ( prev : FieldState ) => ( {
328
329
...prev ,
329
330
meta : {
330
331
...prev . meta ,
331
- warning : result . error
332
+ warning : ( result as WarningObject ) ? .error
332
333
}
333
334
} ) ) ;
334
335
} else {
You can’t perform that action at this time.
0 commit comments