I'm currently working with React and TypeScript, and I need to verify if my groupID exists in an array of [2, 3, 4].
I'm unsure about the validity of my validationSchema as I am encountering issues with a keyword that seems to be missing from the const. My validationSchema is stored in a separate file.
Can anyone provide some guidance?
export const validationSchema = Yup.object().shape
({
text: Yup
.string()
.defined()
.max(2048, "Az üzenet szövege túl hosszú,"),
groupID: Yup
.number()
.min(1),
queryParam: Yup
.string()
.when("is_in_list",
{
is: [2, 3, 4].includes(this.parent.groupID),
then: Yup
.string()
.defined("Kötelező mező."),
otherwise: Yup
.string()
.nullable()
}),
isVoteType: Yup
.boolean(),
positiveAnswer: Yup
.string()
.when("isVoteType",
{
is: true,
then: Yup.string()
.required("Kötelező mező.")
}),
negativeAnswer: Yup
.string()
.when("isVoteType",
{
is: true,
then: Yup.string()
.required("Kötelező mező.")
})
});