Skip to content

Instantly share code, notes, and snippets.

@ShunYamauchi
Last active November 18, 2021 12:59
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/efd5d3fe98c49f45b54f41c2f46f76fd to your computer and use it in GitHub Desktop.
Save ShunYamauchi/efd5d3fe98c49f45b54f41c2f46f76fd to your computer and use it in GitHub Desktop.
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