我试图在错误消息中输出字段值,执行如下操作:
const schema = commonSchema.concat(Yup.object().shape({
name: Yup
.string()
.oneOf(
[Yup.ref('oldName'), null],
`Name must match oldName - ${Yup.ref('oldName').getValue()}`
)
.required('name'),
}));
Run Code Online (Sandbox Code Playgroud)
这给了 TypeError:无法读取未定义的属性“父”。在错误消息中访问字段值的正确方法是什么?