[英]Yup Validation For AutoComplete in Material UI
如果兩個字段中的任何一個為真,我應該需要一個自動完成功能。 我的問題是,當我單擊提交時,它輸出An unhandled error was caught during validation in <Formik validationSchema /> TypeError: You cannot
concat() schema's of different types: string and object
category: string().when(['new', 'exist'], {
is: false,
then: object({
id: string(),
name: string(),
})
.nullable()
.required('field is required'),
}),
new: bool().nullable(),
exist: bool().nullable(),
如果我正確閱讀了錯誤消息,那么您在category:
之后的string()
似乎應該替換為object()
,即:
category: object().when(['new', 'exist'], {
is: false,
then: object({
id: string(),
name: string(),
})
.nullable()
.required('field is required'),
}),
new: bool().nullable(),
exist: bool().nullable(),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.