Skip to content

Instantly share code, notes, and snippets.

@ShunYamauchi
Created November 18, 2021 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShunYamauchi/51700839f1e399f911005b4a9a86595e to your computer and use it in GitHub Desktop.
Save ShunYamauchi/51700839f1e399f911005b4a9a86595e to your computer and use it in GitHub Desktop.
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