Skip to content

Commit

Permalink
[fix]: float point precision bug in form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
a8081 committed Apr 24, 2024
1 parent 4126ae8 commit 2e98d40
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/features/experiment/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const ExperimentFormComponent: React.FC<ExperimentFormProperties> = ({ onSubmit,
return tot;
}, 0);

if (sum != 1.0) setFormError('imbalancedCase', { type: 'required', message: t('features.experiment.form.errors.imbalancedCaseSumDistinctOfOne') as string });
if ((Math.round(sum * 1e12) / 1e12) != 1.0) setFormError('imbalancedCase', { type: 'required', message: t('features.experiment.form.errors.imbalancedCaseSumDistinctOfOne') as string });
}
}
if (Validations.isBlank(data.name)) setFormError('name', { type: 'required', message: t('features.experiment.form.errors.nameRequired') as string })
Expand Down

0 comments on commit 2e98d40

Please sign in to comment.