diff --git a/src/animaltrack/web/routes/actions.py b/src/animaltrack/web/routes/actions.py index ea6c72e..b40f929 100644 --- a/src/animaltrack/web/routes/actions.py +++ b/src/animaltrack/web/routes/actions.py @@ -145,14 +145,15 @@ async def animal_cohort(request: Request): except ValueError: return _render_cohort_error(locations, species_list, "Count must be a valid number", form) - # Validate required fields - if not species: + # Validate required fields - check for empty or placeholder values + # Note: disabled placeholder options may send their text instead of empty value + if not species or species not in ("duck", "goose"): return _render_cohort_error(locations, species_list, "Please select a species", form) - if not location_id: + if not location_id or len(location_id) != 26: return _render_cohort_error(locations, species_list, "Please select a location", form) - if not life_stage: + if not life_stage or life_stage not in ("hatchling", "juvenile", "subadult", "adult"): return _render_cohort_error(locations, species_list, "Please select a life stage", form) - if not origin: + if not origin or origin not in ("hatched", "purchased", "rescued", "unknown"): return _render_cohort_error(locations, species_list, "Please select an origin", form) # Create payload