Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormItem 组件 rules 都 validator 类型错误 #2339

Closed
zhangminggeek opened this issue Jun 11, 2024 · 0 comments · Fixed by #2406
Closed

FormItem 组件 rules 都 validator 类型错误 #2339

zhangminggeek opened this issue Jun 11, 2024 · 0 comments · Fixed by #2406

Comments

@zhangminggeek
Copy link
Contributor

NutUI React 包名

@nutui/nutui-react-taro

NutUI React 版本号

2.8.6

平台

weapp

重现链接

https://codesandbox.io/p/sandbox/nutui-react-2x-demo-fg4vxd?file=/src/App.tsx

重现步骤

源码地址:https://github.com/jdf2e/nutui-react/blob/next/src/packages/formitem/types.ts

export interface FormItemRule extends FormItemRuleWithoutValidator {
  validator?: (
    ruleCfg: FormItemRuleWithoutValidator,
    value: string
  ) => boolean | string | Promise<boolean | string>
}

validator 中参数 value 不该写死 string,哪怕 any 类型也比 string 强啊

可以参考 react-component 的 form 类型设计 https://github.com/react-component/field-form/blob/master/src/interface.ts

期望的结果是什么?

validator 回调参数类型错误

实际的结果是什么?

validator 回调参数类型不准确

环境信息

No response

其他补充信息

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant