【发布时间】:2020-06-10 21:15:58
【问题描述】:
我正在使用在模式上定义的 Formik React Form 和 Yup 验证:
export const Contact = yup.object<IContact>().shape({
contactName: yup
.string()
.trim('The contact name cannot include leading and trailing spaces')
.strict(true)
.min(1, 'The contact name needs to be at least 1 char')
.max(512, 'The contact name cannot exceed 512 char')
.required('The contact Name is required'),
});
有没有办法让 Yup 修剪空白而不显示消息?那么在提交表单时自动修剪空格?
【问题讨论】:
-
你能展示你的完整代码吗?
标签: reactjs typescript validation formik yup