Skip to content

Commit

Permalink
implemented Partner.Validate
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Sep 3, 2024
1 parent 77523c8 commit 9fc5e27
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions golang/domonda/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23

require (
github.com/domonda/go-types v0.0.0-20240822142828-3b45a403e1e2
github.com/ungerik/go-fs v0.0.0-20240702143946-3ecb6733945d
github.com/ungerik/go-fs v0.0.0-20240829170221-72a8ff83f83f
)

require (
Expand All @@ -14,7 +14,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f // indirect
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 // indirect
github.com/jhillyerd/enmime v1.2.0 // indirect
github.com/jhillyerd/enmime v1.3.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
Expand Down
8 changes: 4 additions & 4 deletions golang/domonda/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f h1:3BSP1Tbs2djlpprl7w
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 h1:iCHtR9CQyktQ5+f3dMVZfwD2KWJUgm7M0gdL9NGr8KA=
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/jhillyerd/enmime v1.2.0 h1:dIu1IPEymQgoT2dzuB//ttA/xcV40NMPpQtmd4wslHk=
github.com/jhillyerd/enmime v1.2.0/go.mod h1:FRFuUPCLh8PByQv+8xRcLO9QHqaqTqreYhopv5eyk4I=
github.com/jhillyerd/enmime v1.3.0 h1:LV5kzfLidiOr8qRGIpYYmUZCnhrPbcFAnAFUnWn99rw=
github.com/jhillyerd/enmime v1.3.0/go.mod h1:6c6jg5HdRRV2FtvVL69LjiX1M8oE0xDX9VEhV3oy4gs=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
Expand All @@ -42,8 +42,8 @@ github.com/teamwork/tnef v0.0.0-20200108124832-7deabccfdb32 h1:j15wq0XPAY/HR/0+d
github.com/teamwork/tnef v0.0.0-20200108124832-7deabccfdb32/go.mod h1:v7dFaQrF/4+curx7UTH9rqTkHTgXqghfI3thANW150o=
github.com/teamwork/utils v0.0.0-20220314153103-637fa45fa6cc h1:BidxxRk9kopF5IGEyosTRtanaYVYTUbGJh9eULOhv04=
github.com/teamwork/utils v0.0.0-20220314153103-637fa45fa6cc/go.mod h1:3Fn0qxFeRNpvsg/9T1+btOOOKkd1qG2nPYKKcOmNpcs=
github.com/ungerik/go-fs v0.0.0-20240702143946-3ecb6733945d h1:ldn6b+zKWH52GaUyv7GPyaIGKm8tLYtdMePw6lHdoAw=
github.com/ungerik/go-fs v0.0.0-20240702143946-3ecb6733945d/go.mod h1:+8Ezjyw6fCooNzoVofQIhWLXLe6E23nZ/9cfQ79Wzo0=
github.com/ungerik/go-fs v0.0.0-20240829170221-72a8ff83f83f h1:jb5ZQXhC4aBpfqmzSyIPdgu+oUNw/b1V8ntKIBPfqpU=
github.com/ungerik/go-fs v0.0.0-20240829170221-72a8ff83f83f/go.mod h1:nMIa35zyLzk4K3tTLL+AAsOZ9Q+0lgX/lxYubEwCZSY=
github.com/ungerik/go-reflection v0.0.0-20240110134735-61cada706fec h1:QiS/w0cXNtHs0xhs+Pa2Pp71CTeM9z7zVgbxV+CvezM=
github.com/ungerik/go-reflection v0.0.0-20240110134735-61cada706fec/go.mod h1:6mOx6LfN4Xbb4fyHO6syugCjbx88cgpbxekcx4W1mpM=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
Expand Down
32 changes: 29 additions & 3 deletions golang/domonda/partner.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,36 @@ type Partner struct {

func (p *Partner) Validate() error {
var err error
if p.Name == "" {
err = errors.Join(err, fmt.Errorf("empty Partner.Name"))
if p.Name.IsEmpty() {
err = errors.Join(err, errors.New("empty Partner.Name"))
}
if e := p.Country.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.Country %q: %w", p.Country, e))
}
if e := p.Email.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.Email %q: %w", p.Email, e))
}
if e := p.VATIDNo.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.VATIDNo %q: %w", p.VATIDNo, e))
}
if e := p.VendorAccountNumber.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.VendorAccountNumber %q: %w", p.VendorAccountNumber, e))
}
if e := p.ClientAccountNumber.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.ClientAccountNumber %q: %w", p.ClientAccountNumber, e))
}
if e := p.IBAN.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.IBAN %q: %w", p.IBAN, e))
}
if e := p.BIC.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.BIC %q: %w", p.BIC, e))
}
if e := p.IBAN2.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.IBAN2 %q: %w", p.IBAN2, e))
}
if e := p.BIC2.Validate(); e != nil {
err = errors.Join(err, fmt.Errorf("invalid Partner.BIC2 %q: %w", p.BIC2, e))
}
// TODO
return err
}

Expand Down

0 comments on commit 9fc5e27

Please sign in to comment.