mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
feat(form): export ValidationError (#755)
* feat(form): export ValidationError * fix: export FormValidationError Co-authored-by: yugang.cao <yugang.cao@tusimple.ai>
This commit is contained in:
parent
12946303e9
commit
cf38115b80
@ -5,6 +5,7 @@
|
||||
### Feats
|
||||
|
||||
- `n-loading-bar` add `loading-bar-style` props, closes [#457](https://github.com/TuSimple/naive-ui/issues/457).
|
||||
- `n-form` export `FormValidationError` type.
|
||||
|
||||
### Fixes
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
### Feats
|
||||
|
||||
- `n-loading-bar` 新增 `loading-bar-style` 属性,关闭 [#457](https://github.com/TuSimple/naive-ui/issues/457)
|
||||
- `n-form` 导出 `FormValidationError` 类型
|
||||
|
||||
### Fixes
|
||||
|
||||
|
@ -79,14 +79,14 @@ Accept all props from FormItem & [GridItem](grid#GridItem-Props)
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| validate | `(validateCallback?: (errors?: Array<ValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean) => Promise<void>` | Validate the form. The rejection value type of returned promise is `Array<ValidationError>`. |
|
||||
| validate | `(validateCallback?: (errors?: Array<FormValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean) => Promise<void>` | Validate the form. The rejection value type of returned promise is `Array<FormValidationError>`. |
|
||||
| restoreValidation | `() => void` | Restore validate. |
|
||||
|
||||
### FormItem, FormItemGi Methods
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| validate | `(options: { trigger?: string, callback?: (errors?: Array<ValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean, options?: AsyncValidatorOptions }) => Promise<void>` | Validate the form item. The rejection value type of returned promise is `Array<ValidationError>`. If trigger is not set, all rules of the item will be applied. `shouldRuleBeApplied` can filter rules after they are filtered by the trigger. |
|
||||
| validate | `(options: { trigger?: string, callback?: (errors?: Array<FormValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean, options?: AsyncValidatorOptions }) => Promise<void>` | Validate the form item. The rejection value type of returned promise is `Array<FormValidationError>`. If trigger is not set, all rules of the item will be applied. `shouldRuleBeApplied` can filter rules after they are filtered by the trigger. |
|
||||
| restoreValidation | `() => void` | Restore validate. |
|
||||
|
||||
About AsyncValidatorOptions, see <n-a href="https://github.com/yiminghe/async-validator">async-validator</n-a>.
|
||||
|
@ -80,14 +80,14 @@ validator-debug
|
||||
|
||||
| 名称 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| validate | `(validateCallback?: (errors?: Array<ValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean) => Promise<void>` | 验证表单,Promise rejection 的返回值类型是 `Array<ValidationError>` |
|
||||
| validate | `(validateCallback?: (errors?: Array<FormValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean) => Promise<void>` | 验证表单,Promise rejection 的返回值类型是 `Array<FormValidationError>` |
|
||||
| restoreValidation | `() => void` | 还原到未校验的状态 |
|
||||
|
||||
### FormItem, FormItemGi Methods
|
||||
|
||||
| 名称 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| validate | `(options: { trigger?: string, callback?: (errors?: Array<ValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean, options?: AsyncValidatorOptions }) => Promise<void>` | 验证表项,Promise rejection 的返回值类型是 `Array<ValidationError>`。如果设定 `trigger`,这一个表项全部的规则都会被使用。`shouldRuleBeApplied` 可以用来进一步过滤已经经过 `trigger` 筛选的规则 |
|
||||
| validate | `(options: { trigger?: string, callback?: (errors?: Array<FormValidationError>) => void, shouldRuleBeApplied?: FormItemRule => boolean, options?: AsyncValidatorOptions }) => Promise<void>` | 验证表项,Promise rejection 的返回值类型是 `Array<FormValidationError>`。如果设定 `trigger`,这一个表项全部的规则都会被使用。`shouldRuleBeApplied` 可以用来进一步过滤已经经过 `trigger` 筛选的规则 |
|
||||
| restoreValidation | `() => void` | 还原到未校验的状态 |
|
||||
|
||||
关于 AsyncValidatorOptions,参考 <n-a href="https://github.com/yiminghe/async-validator">async-validator</n-a>。
|
||||
|
@ -14,7 +14,8 @@ export type {
|
||||
FormInst,
|
||||
FormItemInst,
|
||||
FormItemRule,
|
||||
FormRules
|
||||
FormRules,
|
||||
FormValidationError
|
||||
} from './src/interface'
|
||||
|
||||
// deprecated
|
||||
|
@ -75,6 +75,8 @@ export type FormValidateCallback = (errors?: ErrorList[]) => void
|
||||
export type FormValidate = ((callback?: FormValidateCallback) => void) &
|
||||
(() => Promise<void>)
|
||||
|
||||
export type FormValidationError = ErrorList
|
||||
|
||||
export interface FormInst {
|
||||
validate: FormValidate
|
||||
restoreValidation: () => void
|
||||
|
Loading…
Reference in New Issue
Block a user