Skip to content

Commit

Permalink
Update Yup when
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-zakrzewski committed Apr 9, 2024
1 parent 7cfbfb6 commit a8bbb46
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions verification/curator-service/ui/src/components/CaseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,43 +284,47 @@ 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')
.max(120, 'Age must be between 0 and 120')
.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')
.max(120, 'Age must be between 0 and 120')
.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()
Expand Down

0 comments on commit a8bbb46

Please sign in to comment.