小编Aze*_*eez的帖子

类型错误:分支不是使用 yup 进行验证的函数

当尝试使用 Yup 库进行验证时,以下函数中会抛出错误“branch is not a function”(我已注释掉 schema.validate 函数,在这种情况下我的代码可以正常工作,但使用 schema 则无法正常工作):


const schema = Yup.object({
  boundary: Yup.string().required('Boundary is required'),
  boundaryConstructionDate: Yup.string().when('boundary', {
    is: (value) => value === 'yes',
    then: Yup.string().required('Boundary construction date is required'),
    otherwise: Yup.string(),
  }),
  toilet: Yup.string().required('Toilet is required'),
  toiletConstructionDate: Yup.string().when('toilet', {
    is: (value) => value === 'yes',
    then: Yup.string().required('Toilet construction date is required'),
    otherwise: Yup.string(),
  }),
  payjal: Yup.string().required('Payjal is required'),
  ramp: Yup.string().required('Ramp is required'),
  rampConstructionDate: Yup.string().when('ramp', {
    is: (value) => value === 'yes',
    then: Yup.string().required('Ramp construction date …
Run Code Online (Sandbox Code Playgroud)

mongoose node.js express reactjs yup

1
推荐指数
1
解决办法
3110
查看次数

标签 统计

express ×1

mongoose ×1

node.js ×1

reactjs ×1

yup ×1