diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index e5e31b11c..2161306ee 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -165,7 +165,6 @@ const validationSchema = computed(() => { .required('form.validation.contributionMemo.required'), hours: string() .typeError({ key: 'form.validation.hours.typeError', values: { min: 0.01, max: maxHours } }) - .required() .transform((currentValue) => !currentValue || typeof currentValue !== 'string' ? currentValue @@ -179,18 +178,22 @@ const validationSchema = computed(() => { return /^\d+(\.\d{0,2})?$/.test(value.toString()) }) // min and max are not working with string, so we need to do it manually - .test('min-hours', 'form.validation.hours.min', (value) => { - if (value === undefined || value === null || Number(value).isNaN()) { + .test('min-hours', { key: 'form.validation.hours.min', values: { min: 0.01 } }, (value) => { + if (value === undefined || value === null || Number.isNaN(parseFloat(value))) { return false } return parseFloat(value) >= 0.01 }) - .test('max-hours', 'form.validation.hours.max', (value) => { - if (value === undefined || value === null || Number(value).isNaN()) { - return false - } - return parseFloat(value) <= maxHours - }), + .test( + 'max-hours', + { key: 'form.validation.hours.max', values: { max: maxHours } }, + (value) => { + if (value === undefined || value === null || Number.isNaN(parseFloat(value))) { + return false + } + return parseFloat(value) <= maxHours + }, + ), amount: number().min(0.01).max(maxAmounts), }) })