Last active
November 18, 2021 12:59
-
-
Save ShunYamauchi/efd5d3fe98c49f45b54f41c2f46f76fd 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
object().shape( | |
{ | |
lunchStyles: array().min(1, 'お昼ごはんの選択は必須です。'), | |
salads: array().when( | |
['lunchStyles', 'soups'], | |
{ | |
is: ( | |
lunchStyles: string[], | |
soups: string[] | |
) => | |
lunchStyles.includes('lunchBox') && | |
soups.length === 0, | |
then: array().min( | |
1, | |
'お弁当の場合は、スープまたはサラダの入力が必須です。' | |
) | |
} | |
), | |
soups: array().when( | |
['lunchStyles', 'salads'], | |
{ | |
is: ( | |
lunchStyles: string[], | |
salads: string[] | |
) => | |
lunchStyles.includes('lunchBox') && | |
salads.length === 0, | |
then: array().min( | |
1, | |
'お弁当の場合は、スープまたはサラダの入力が必須です。' | |
) | |
} | |
) | |
}, | |
[['salads', 'soups']] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment