Created
November 18, 2021 12:43
-
-
Save ShunYamauchi/51700839f1e399f911005b4a9a86595e 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
const validateLunchBoxStyle = function (this: any) { | |
const { | |
lunchStyles, | |
soups, | |
salads | |
} = this.parent | |
return !( | |
lunchStyles.includes('lunchBox') && | |
soups.length === 0 && | |
salads.length === 0 | |
) | |
} | |
object().shape( | |
{ | |
lunchStyles: array().min(1, 'お昼ごはんの選択は必須です。'), | |
salads: array().test( | |
'salads_validation', | |
'お弁当の場合は、スープまたはサラダの入力が必須です。', | |
validateLunchBoxStyle | |
), | |
soups: array().test( | |
'soups_validation', | |
'お弁当の場合は、スープまたはサラダの入力が必須です。', | |
validateLunchBoxStyle | |
) | |
}, | |
[['salads', 'soups']] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment