field-form icon indicating copy to clipboard operation
field-form copied to clipboard

[feat] please export `Validator` related types, and in `antd`

Open JounQin opened this issue 4 years ago • 1 comments

I'd like to write custom validators:

import type { Validator } from 'antd' // or at least `import type { Validator } from 'rc-field-form'`

export const strongPasswordValidator: Validator = (rule, value) => {}

JounQin avatar Aug 30 '21 09:08 JounQin

My current workaround:

import type { RuleObject } from 'antd/lib/form'
import type { StoreValue } from 'antd/lib/form/interface'

/**
 * @see https://github.com/react-component/field-form/issues/330
 */
export type Validator = (
  rule: RuleObject,
  value: StoreValue,
  callback: (error?: string) => void,
) => Promise<void> | void

JounQin avatar Aug 30 '21 09:08 JounQin