Created
October 9, 2019 00:41
-
-
Save up209d/4735312ce800191062b6b6728af2d5b2 to your computer and use it in GitHub Desktop.
Yup test reading values from current form state
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 default yup.object().test('bothFieldsCannotBeEmpty', 'Both fields cannot be empty', values => { | |
const { matchingInclusionRule, matchingExclusionRule } = values; | |
return ( | |
!!matchingInclusionRule || | |
!!matchingExclusionRule || | |
new yup.ValidationError(`Inclusion Rule & Exclusion Rule cannot be left both empty.`, null, 'matchingInclusionRule') | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment