Validate precipitation probabilities and ice wording

This commit is contained in:
2026-08-13 00:48:40 +00:00
parent 8e49ba88c7
commit 730929e2ed
10 changed files with 142 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package weatherdata
import (
"encoding/json"
"math"
"time"
)
@@ -137,6 +138,12 @@ func (p ForecastPeriod) HasUsableTimeBounds() bool {
return !p.StartTime.IsZero() && !p.EndTime.IsZero() && p.EndTime.After(p.StartTime)
}
// HasValidPrecipitationProbability reports whether an optional probability is a finite percentage.
func (p ForecastPeriod) HasValidPrecipitationProbability() bool {
value := p.ProbabilityOfPrecipitationPercent
return value == nil || !math.IsNaN(*value) && !math.IsInf(*value, 0) && *value >= 0 && *value <= 100
}
type AlertRun struct {
AsOf *time.Time `json:"asOf,omitempty"`
Alerts []json.RawMessage `json:"alerts,omitempty"`