Skip to content

Commit

Permalink
fix: ensure day-based parameters are at least 1
Browse files Browse the repository at this point in the history
To ensure proper integration in the algorithm.
  • Loading branch information
ivan-aksamentov committed Apr 13, 2020
1 parent b9d3597 commit b8310b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/components/Main/Scenario/ScenarioCardEpidemiological.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function ScenarioCardEpidemiological({ errors, touched }: ScenarioCardEpidemiolo
label={`${t('Latency')} [${t('days')}]`}
help={t('Time from infection to onset of symptoms (here onset of infectiousness)')}
step={0.1}
min={0}
min={1}
errors={errors}
touched={touched}
/>
Expand All @@ -58,7 +58,7 @@ function ScenarioCardEpidemiological({ errors, touched }: ScenarioCardEpidemiolo
'Average number of days a person is infectious. Over this time, R0 infections happen on average. Together with the latency time, this defines the serial interval. The longer the serial interval, the slower the outbreak.',
)}
step={0.1}
min={0}
min={1}
errors={errors}
touched={touched}
/>
Expand All @@ -84,7 +84,7 @@ function ScenarioCardEpidemiological({ errors, touched }: ScenarioCardEpidemiolo
label={`${t('Hospital stay')} [${t('days')}]`}
help={t('Average number of days a severe case stays in regular hospital beds')}
step={0.1}
min={0}
min={1}
errors={errors}
touched={touched}
/>
Expand All @@ -93,7 +93,7 @@ function ScenarioCardEpidemiological({ errors, touched }: ScenarioCardEpidemiolo
label={`${t('ICU stay')} [${t('days')}]`}
help={t('Average number of days a critical case stays in the ICU')}
step={0.1}
min={0}
min={1}
errors={errors}
touched={touched}
/>
Expand Down
9 changes: 5 additions & 4 deletions src/components/Main/validation/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ageRegions = [...ageDistributionNames, CUSTOM_COUNTRY_NAME]
const MSG_REQUIRED = i18next.t('Value is required')
const MSG_NON_NEGATIVE = i18next.t('Should be non-negative (or zero)')
const MSG_POSITIVE = i18next.t('Should be strictly positive (non-zero)')
const MSG_AT_LEAST_ONE_DAY = i18next.t('Should be at least one day or greater')

export function dateRange() {
return yup.object({
Expand Down Expand Up @@ -38,13 +39,13 @@ export const schema = yup.object().shape({
epidemiological: yup.object().shape({
r0: yup.number().required(MSG_REQUIRED).min(0, MSG_NON_NEGATIVE),

latencyTime: yup.number().required(MSG_REQUIRED).positive(MSG_POSITIVE),
latencyTime: yup.number().required(MSG_REQUIRED).min(1, MSG_AT_LEAST_ONE_DAY),

infectiousPeriod: yup.number().required(MSG_REQUIRED).positive(MSG_POSITIVE),
infectiousPeriod: yup.number().required(MSG_REQUIRED).min(1, MSG_AT_LEAST_ONE_DAY),

lengthHospitalStay: yup.number().required(MSG_REQUIRED).positive(MSG_POSITIVE),
lengthHospitalStay: yup.number().required(MSG_REQUIRED).min(1, MSG_AT_LEAST_ONE_DAY),

lengthICUStay: yup.number().required(MSG_REQUIRED).positive(MSG_POSITIVE),
lengthICUStay: yup.number().required(MSG_REQUIRED).min(1, MSG_AT_LEAST_ONE_DAY),

seasonalForcing: yup.number().required(MSG_REQUIRED).min(0, MSG_NON_NEGATIVE),

Expand Down

0 comments on commit b8310b2

Please sign in to comment.