From a8bbb465c3225e02dca2c41fe2df36a51a69901d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Zakrzewski?= Date: Tue, 9 Apr 2024 15:02:09 +0200 Subject: [PATCH] Update Yup when --- .../ui/src/components/CaseForm.tsx | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/verification/curator-service/ui/src/components/CaseForm.tsx b/verification/curator-service/ui/src/components/CaseForm.tsx index a8846eac4..5697ab60d 100644 --- a/verification/curator-service/ui/src/components/CaseForm.tsx +++ b/verification/curator-service/ui/src/components/CaseForm.tsx @@ -284,9 +284,10 @@ const NewCaseValidation = Yup.object().shape( .when('demographics.maxAge', { is: (maxAge: number | string) => maxAge !== undefined && maxAge !== '', - then: Yup.number().required( - 'Min age required in range. Minimum value is 0.', - ), + then: () => + Yup.number().required( + 'Min age required in range. Minimum value is 0.', + ), }), maxAge: Yup.number() .min(0, 'Age must be between 0 and 120') @@ -294,14 +295,15 @@ const NewCaseValidation = Yup.object().shape( .when('demographics.minAge', { is: (minAge: number | string) => minAge !== undefined && minAge !== '', - then: Yup.number() - .min( - Yup.ref('demographics.minAge'), - 'Max age must be greater than than min age', - ) - .required( - 'Max age required in range. Maximum value is 120.', - ), + then: () => + Yup.number() + .min( + Yup.ref('demographics.minAge'), + 'Max age must be greater than than min age', + ) + .required( + 'Max age required in range. Maximum value is 120.', + ), }), age: Yup.number() .min(0, 'Age must be between 0 and 120') @@ -309,18 +311,20 @@ const NewCaseValidation = Yup.object().shape( .when('demographics.minAge', { is: (minAge: number | string) => minAge !== undefined && minAge !== '', - then: Yup.number().oneOf( - [undefined], - 'Cannot enter age and age range', - ), + then: () => + Yup.number().oneOf( + [undefined], + 'Cannot enter age and age range', + ), }) .when('demographics.maxAge', { is: (maxAge: number | string) => maxAge !== undefined && maxAge !== '', - then: Yup.number().oneOf( - [undefined], - 'Cannot enter age and age range', - ), + then: () => + Yup.number().oneOf( + [undefined], + 'Cannot enter age and age range', + ), }), }), numCases: Yup.number()