Created
August 5, 2020 09:37
-
-
Save Cloudo/65c33c801fca701ce355bc5f9bc475b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const schemaThirdStepPoll = Yup.object().shape<Partial<PollOrOssParams>>({ | |
questions: Yup.array() | |
.ensure() | |
.of( | |
// @ts-ignore | |
Yup.lazy<any>((item, options) => { | |
const itemIndex = options.parent.indexOf ? options.parent.indexOf(item) : -1; | |
let description = Yup.string().min(50); | |
if (itemIndex > 0) { | |
description = description.required(); | |
} | |
return Yup.object().shape({ | |
text: Yup.string().required().min(20), | |
type: Yup.string().required(), | |
description, | |
answers: Yup.array() | |
.ensure() | |
.of( | |
Yup.object().shape({ | |
answer: Yup.string().required(), | |
}) | |
), | |
}); | |
}) | |
), | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment