如果字符串为空并且仍然抛出错误,则 yup 字符串上的 .notRequired 不起作用

SIm*_*dad 5 javascript reactjs yup

我正在尝试验证一个字符串,如果为空则不应验证,但如果有字符则应开始验证。我尝试过,但没有成功

iban: yup
      .string()
      .notRequired()
      .min(5, 'Minimum of 5')
      .max(34, 'Maximum of 34'),
Run Code Online (Sandbox Code Playgroud)

如果 '' 中的空字符串仍然抛出至少 5 个错误,我该如何解决这个问题?

Sve*_*ode 2

根据github上的文档,它说传入 undefined 是可以接受的,但是空字符串不等于 undefined。

mixed.notRequired(): Schema
  Mark the schema as not required. Passing undefined as value will not fail validation.
Run Code Online (Sandbox Code Playgroud)