Skip to content

Commit 4a31fd3

Browse files
authored
Merge pull request #538 from pumano/master
fix: update form validation typings #526
2 parents 2f81ea7 + 89875fd commit 4a31fd3

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

types/form/form.d.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ declare interface FieldDecoratorOptions {
186186
preserve?: boolean;
187187
}
188188

189+
export type ValidateCallback = (errors: Error[], values: any) => void;
190+
189191
export interface WrappedFormUtils {
190192
/**
191193
* Two-way binding for form, single file template can be bound using the directive v-decorator.
@@ -240,7 +242,7 @@ export interface WrappedFormUtils {
240242
* If you don't specify a parameter, all the fields will be reset.
241243
* @type Function (Function([names: string[]]))
242244
*/
243-
resetFields(names: string[]): void;
245+
resetFields(names?: string[]): void;
244246

245247
/**
246248
* Set value and error state of fields
@@ -259,24 +261,25 @@ export interface WrappedFormUtils {
259261
* If you don't specify the parameter of fieldNames, you will validate all fields.
260262
* @type Function
261263
*/
262-
validateFields(
263-
fieldNames: string[],
264-
options: ValidateFieldOptions,
265-
callback: (erros: Error[], values: any) => any,
266-
): void;
264+
validateFields(fieldNames: string[], options: ValidateFieldOptions, callback: ValidateCallback): void;
265+
validateFields(fieldNames: string[], callback: ValidateCallback): void;
266+
validateFields(options: ValidateFieldOptions, callback: ValidateCallback): void;
267+
validateFields(callback: ValidateCallback): void;
268+
validateFields(): void;
267269

268270
/**
269271
* This function is similar to validateFields, but after validation, if the target field is not in visible area of form,
270272
* form will be automatically scrolled to the target field area.
271273
* @type Function
272274
*/
273-
validateFieldsAndScroll(
274-
fieldNames: string[],
275-
options: ValidateFieldOptions,
276-
callback: (erros: Error[], values: any) => any,
277-
): void;
275+
validateFieldsAndScroll(fieldNames?: string[], options?: Object, callback?: ValidateCallback): void;
276+
validateFieldsAndScroll(fieldNames?: string[], callback?: ValidateCallback): void;
277+
validateFieldsAndScroll(options?: Object, callback?: ValidateCallback): void;
278+
validateFieldsAndScroll(callback?: ValidateCallback): void;
279+
validateFieldsAndScroll(): void;
278280
}
279281

282+
280283
export interface IformCreateOption {
281284
/**
282285
* Only supports the use of Form.create({})(CustomizedForm). declare props on form(like vue props)

0 commit comments

Comments
 (0)