From 7b5c2dd9560ccacc88a563f5bd38e07476e06116 Mon Sep 17 00:00:00 2001 From: Sebastien Delaux Date: Wed, 11 Feb 2026 15:17:59 +1300 Subject: [PATCH] Enforcing lenght of 2 for times in the case of a range --- src/oceanum/datamesh/query.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/oceanum/datamesh/query.py b/src/oceanum/datamesh/query.py index b835f9b..c868624 100644 --- a/src/oceanum/datamesh/query.py +++ b/src/oceanum/datamesh/query.py @@ -289,6 +289,16 @@ class TimeFilter(BaseModel): description="Resampling method applied when reducing tempral resolution. Only valid with range type", ) + @field_validator("times") + @classmethod + def validate_times(cls, v, info): + if info.data.get("type") == TimeFilterType.range: + if len(v) != 2: + raise ValueError( + "For TimeFilters of type='range', times must contain exactly 2 values: [timestart, timeend] which must be of type Timestamp, Timedelta or None" + ) + return v + class AggregateOps(str, Enum): mean = "mean"