From dbe1c40e1621bfa4d4a22590cce0ddd505cf90dd Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Mon, 22 Mar 2021 23:46:57 -0500 Subject: [PATCH] Add method to validate Breathe struct --- lights.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lights.go b/lights.go index 3270b36..9d7b9b8 100644 --- a/lights.go +++ b/lights.go @@ -3,6 +3,7 @@ package lifx import ( //"crypto/tls" "encoding/json" + "errors" "net/http" "time" ) @@ -116,6 +117,13 @@ func NewBreathe() Breathe { return b } +func (b *Breathe) Valid() error { + if b.Peak < 0 || b.Peak > 1 { + return errors.New("peak must be between 0.0 and 1.0") + } + return nil +} + func (c *Client) SetState(selector string, state State) (*LifxResponse, error) { var ( err error