Last active
August 26, 2023 20:01
-
-
Save victor-ponamariov/ed5040b2339e68d0ea14d24198444cc5 to your computer and use it in GitHub Desktop.
Useful JS snippets
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
// How to validate a field that depends on another variable, rather than a field in <Form>, in vee-validate 4 | |
return yup.object().shape({ | |
// Set empty array in .when | |
businessTripPurpose: yup.string().when([], { | |
is: () => props.trip.reason.type === 'business_trip', | |
then: schema => schema.required('The field is required') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment