Skip to content

Commit

Permalink
Fix litter size validation in IndividualBreedingForm to ensure proper…
Browse files Browse the repository at this point in the history
… numeric evaluation

- Updated litter size comparison to use Number() for accurate numeric evaluation, preventing issues with string comparisons.
- This change enhances validation logic and improves user feedback regarding litter size constraints, ensuring accurate data handling in the IndividualBreedingForm component.
  • Loading branch information
jhagberg committed Jan 14, 2025
1 parent e55a29c commit be929a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/src/individual_breeding_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export function IndividualBreedingForm({

if (
(userInput.birth_date, userInput.litter_size) !== null &&
!(userInput.litter_size > 0)
!(Number(userInput.litter_size) > 0)
) {
userMessage("Ange en kullstorlek större än 0", "warning");
return false;
Expand Down Expand Up @@ -365,7 +365,7 @@ export function IndividualBreedingForm({
const newBirthData: Birth = {
date: breeding.birth_date,
litter_size: breeding.litter_size,
litter_size6w: breeding.litter_size,
litter_size6w: breeding.litter_size6w,
notes: breeding.birth_notes !== "" ? breeding.birth_notes : undefined,
id: newBreeding.breeding_id,
};
Expand Down

0 comments on commit be929a7

Please sign in to comment.