Last active
March 30, 2020 15:35
-
-
Save cybercris/68c61a7ff8408215b25e88dc4e4740b9 to your computer and use it in GitHub Desktop.
optionalSchema
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
const optionalRequiredSchema = yup.object().shape({ | |
optionalObject: yup.lazy(value => { | |
if (value !== undefined) { | |
yup.mixed().notRequired(); | |
} | |
return yup.object().shape({ | |
otherData: yup.string().required() | |
}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment