Validate precipitation probabilities and ice wording
This commit is contained in:
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user