Created
November 18, 2021 12:43
Revisions
-
ShunYamauchi created this gist
Nov 18, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ 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']] )