From 31229399a0e197d97196772ea6797e580a68a96c Mon Sep 17 00:00:00 2001 From: Martin Habbecke Date: Sat, 16 Oct 2021 14:49:30 -0700 Subject: [PATCH] Enable Valid() calls on nil Currency instances This requires changing function Valid() to use a pointer receiver. Nil instances are considered invalid. --- common.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common.go b/common.go index bfbaeb3..dc173ac 100644 --- a/common.go +++ b/common.go @@ -362,7 +362,11 @@ type Currency struct { } // Valid returns whether the Currency is valid according to the OFX spec -func (c Currency) Valid() (bool, error) { +func (c *Currency) Valid() (bool, error) { + if c == nil { + return false, errors.New("Currency is nil") + } + if c.CurRate.IsInt() && c.CurRate.Num().Int64() == 0 { return false, errors.New("CurRate may not be zero") } else if ok, err := c.CurSym.Valid(); !ok {