field-form
field-form copied to clipboard
[feat] please export `Validator` related types, and in `antd`
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) => {}
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