formik - 为什么 yup 验证在匹配特定值时不起作用?
问题描述
我有一个场景,我必须btext
根据另一个字段的 ( ) 值检查字段 ( aText
) 值。仅当其他字段的值等于预定义的参考值 ( predefinedValue
) 时,该检查才适用。下面是我的是的验证码
export const bText = yup
.string()
.when("aText", aText => {
if (aText === predefinedValue) {
console.log("its here");
return yup.string().required("Required");
} else return yup.string();
});
当预定义值匹配bText
且未填充时,验证有效。但即使bText
被填满,验证也不会通过。我哪里错了?
解决方案
推荐阅读
- android - 无法在片段中获得幻灯片效果
- macos - hidd 进程在控制台中生成错误消息
- amazon-web-services - 已解决___使用 AWS S3 到 Webhost 没有给出关键错误
- node.js - Node.js 中的阻塞事件循环仍然存在问题吗?
- python - 我正在尝试在 Pycharm 中使用 Selenium webdriver,您可以在您的项目中使用它还是仅在 Python 控制台中使用它?
- flutter - 如何以简单的方式在本地保存对象列表
- python - 从文本文件中读取 np 数组
- gdb - fedora 中的 debuginfo 处理,如何删除 debuginfo
- javascript - 如何正确使用拼接和切片【Typescript】
- django - 我的 Django 信号超出了最大递归深度