我有三个字段:Formik 形式的referenceMonth(string)、openingDate(string)、endingDate(string)。我会在“ openingDatewhen openingDatis not the samemonth as”中添加一个错误referenceMonth。
export const VALIDATION_SCHEMA = Yup.object().shape({
'referenceMonth' : Yup.number().required(YUP_DEFAULT_ERROR_VALUE),
'openingDate' : Yup.string().when(['referenceMonth', 'openingDate'], {
is: (referenceMonth: string, openingDate: string) =>
referenceMonth !== `${new Date(openingDate).getMonth()}`,
then: Yup.string().required('Select right month')
}),
})
Run Code Online (Sandbox Code Playgroud)
终端显示:错误:循环依赖,节点为:“openingDate”。