From 48542f196138ddfc6a9334e3dd2a02b1c1b335b7 Mon Sep 17 00:00:00 2001 From: Johan Stokking Date: Mon, 29 Aug 2022 16:08:58 +0200 Subject: [PATCH] as: Remove lint warnings and update schema --- .../normalizedpayload/uplink.go | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/pkg/messageprocessors/normalizedpayload/uplink.go b/pkg/messageprocessors/normalizedpayload/uplink.go index 083c988a32..a8fc4fe6fe 100644 --- a/pkg/messageprocessors/normalizedpayload/uplink.go +++ b/pkg/messageprocessors/normalizedpayload/uplink.go @@ -181,24 +181,51 @@ func exclusiveMaximum[T constraints.Ordered](max T) fieldValidator[T] { } var fieldParsers = map[string]fieldParser{ - "time": parseTime(func(dst *Measurement) **time.Time { return &dst.Time }), - "air": object(func(dst *Measurement) **Air { return &dst.Air }), - "air.temperature": parseNumber(func(dst *Measurement) **float64 { return &dst.Air.Temperature }, + "time": parseTime( + func(dst *Measurement) **time.Time { + return &dst.Time + }, + ), + "air": object( + func(dst *Measurement) **Air { + return &dst.Air + }, + ), + "air.temperature": parseNumber( + func(dst *Measurement) **float64 { + return &dst.Air.Temperature + }, minimum(-273.15), ), - "air.relativeHumidity": parseNumber(func(dst *Measurement) **float64 { return &dst.Air.RelativeHumidity }, + "air.relativeHumidity": parseNumber( + func(dst *Measurement) **float64 { + return &dst.Air.RelativeHumidity + }, minimum(0.0), - maximum(1.0), + maximum(100.0), ), - "air.pressure": parseNumber(func(dst *Measurement) **float64 { return &dst.Air.Pressure }, + "air.pressure": parseNumber( + func(dst *Measurement) **float64 { + return &dst.Air.Pressure + }, minimum(900.0), maximum(1100.0), ), - "wind": object(func(dst *Measurement) **Wind { return &dst.Wind }), - "wind.speed": parseNumber(func(dst *Measurement) **float64 { return &dst.Wind.Speed }, + "wind": object( + func(dst *Measurement) **Wind { + return &dst.Wind + }, + ), + "wind.speed": parseNumber( + func(dst *Measurement) **float64 { + return &dst.Wind.Speed + }, minimum(0.0), ), - "wind.direction": parseNumber(func(dst *Measurement) **float64 { return &dst.Wind.Direction }, + "wind.direction": parseNumber( + func(dst *Measurement) **float64 { + return &dst.Wind.Direction + }, minimum(0.0), exclusiveMaximum(360.0), ),