Skip to content

Commit

Permalink
Update validation methods to accept validation scope arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Sep 29, 2024
1 parent 83b1474 commit 820c01d
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 52 deletions.
2 changes: 1 addition & 1 deletion domain/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (m TransferReadyToProceed) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m TransferReadyToProceed) Validate() error {
func (m TransferReadyToProceed) Validate(dogma.TimeoutValidationScope) error {
if m.TransactionID == "" {
return errors.New("TransferReadyToProceed must not have an empty transaction ID")
}
Expand Down
13 changes: 4 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ go 1.23
toolchain go1.23.0

require (
github.com/dogmatiq/configkit v0.14.0
github.com/dogmatiq/dogma v0.14.3
github.com/dogmatiq/configkit v0.14.1-0.20240929215230-3af80ab0c2e9
github.com/dogmatiq/dogma v0.14.4-0.20240926234834-3c0cc27a2ca1
github.com/dogmatiq/projectionkit v0.7.5
github.com/dogmatiq/sqltest v0.3.0
github.com/dogmatiq/testkit v0.17.2
github.com/dogmatiq/testkit v0.17.3-0.20240926003334-8aa7bdf0aec1
github.com/mattn/go-sqlite3 v1.14.23
)

require (
github.com/dogmatiq/cosyne v0.2.0 // indirect
github.com/dogmatiq/dapper v0.6.0 // indirect
github.com/dogmatiq/enginekit v0.13.1-0.20240929214803-d23339eac9a9 // indirect
github.com/dogmatiq/iago v0.4.0 // indirect
github.com/dogmatiq/interopspec v0.5.4 // indirect
github.com/dogmatiq/jumble v0.1.0 // indirect
github.com/dogmatiq/linger v1.1.0 // indirect
github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.3 // indirect
github.com/jackc/pgio v1.0.0 // indirect
Expand All @@ -34,10 +33,6 @@ require (
github.com/sergi/go-diff v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)
24 changes: 10 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dogmatiq/configkit v0.14.0 h1:Gr79vNfmHzEwPn/6QbNSUjitvYk9jJRuLGZSmyXeIEk=
github.com/dogmatiq/configkit v0.14.0/go.mod h1:BMGhQBVMJuTN7KYd99M0qWUEQcuStlTZ2jxykua+MEI=
github.com/dogmatiq/configkit v0.14.1-0.20240929215230-3af80ab0c2e9 h1:kFoWErDVOq1zLJziPDWdXFldyRM8/4zQwdlQ+dNfQI8=
github.com/dogmatiq/configkit v0.14.1-0.20240929215230-3af80ab0c2e9/go.mod h1:WhUSbkhYksNVSbn2Q0LIhkY+bFV2BERNTUMVy4Zsjr4=
github.com/dogmatiq/cosyne v0.2.0 h1:tO957BpS4I9kqSw31ds6Ef4CXvV8zPAqWzbXKElsGWg=
github.com/dogmatiq/cosyne v0.2.0/go.mod h1:dD8EZjbRX7FFw9t6P7l1nwoZbA7YxtOCfl9ZZAHPucU=
github.com/dogmatiq/dapper v0.6.0 h1:hnWUsjnt3nUiC9hmkPvuxrnMd7fYNz1i+/GS3gOx0Xs=
github.com/dogmatiq/dapper v0.6.0/go.mod h1:ubRHWzt73s0MsPpGhWvnfW/Z/1YPnrkCsQv6CUOZVEw=
github.com/dogmatiq/dogma v0.14.3 h1:qwZqU1yqp80toUJcJBdFxLlh6xvlFd7jb7rycmriRUo=
github.com/dogmatiq/dogma v0.14.3/go.mod h1:9lyVA+6V2+E/exV0IrBOrkUiyFwIATEhv+b0vnB2umQ=
github.com/dogmatiq/enginekit v0.12.0 h1:w16TGKVrvvfTejd6HJ2rhVQGZBW3TSK+o3heo7gTEog=
github.com/dogmatiq/enginekit v0.12.0/go.mod h1:o0xikkm3INnWBjIXvJ9LffjdYRhIG3jwFNDyhTk1hcI=
github.com/dogmatiq/dogma v0.14.4-0.20240926234834-3c0cc27a2ca1 h1:SKhtRnDs7CC3ZNMux7lYCxCFz5ZhmeXjvo7/uMNISLo=
github.com/dogmatiq/dogma v0.14.4-0.20240926234834-3c0cc27a2ca1/go.mod h1:9lyVA+6V2+E/exV0IrBOrkUiyFwIATEhv+b0vnB2umQ=
github.com/dogmatiq/enginekit v0.13.1-0.20240929214803-d23339eac9a9 h1:CuQ1OBcfZVfnfAZ4zcqCadsOLVtnfCN4vRsprt/Nncw=
github.com/dogmatiq/enginekit v0.13.1-0.20240929214803-d23339eac9a9/go.mod h1:XsY6KGPIC6zHx1duYDXbHTomqH9y+QOJX/tEiNZE2Qg=
github.com/dogmatiq/iago v0.4.0 h1:57nZqVT34IZxtCZEW/RFif7DNUEjMXgevfr/Mmd0N8I=
github.com/dogmatiq/iago v0.4.0/go.mod h1:fishMWBtzYcjgis6d873VTv9kFm/wHYLOzOyO9ECBDc=
github.com/dogmatiq/interopspec v0.5.4 h1:klyGPy16zUKJartJIJOBZ4JrQ4LxFiY3wgzFTTiNlDk=
github.com/dogmatiq/interopspec v0.5.4/go.mod h1:JL0QFXBTRGH+RgQqExhEUdhtv5Vn802w43RxKQbk8Co=
github.com/dogmatiq/jumble v0.1.0 h1:Cb3ExfxY+AoUP4G9/sOwoOdYX8o+kOLK8+dhXAry+QA=
github.com/dogmatiq/jumble v0.1.0/go.mod h1:FCGV2ImXu8zvThxhd4QLstiEdu74vbIVw9bFJSBcKr4=
github.com/dogmatiq/linger v1.1.0 h1:kGL9sL79qRa6Cr8PhadeJ/ptbum+b48pAaNWWlyVVKg=
Expand All @@ -31,8 +29,8 @@ github.com/dogmatiq/projectionkit v0.7.5 h1:TURoHeSgADg6lDN2+eHU+E3wTgr9CZ8HksOg
github.com/dogmatiq/projectionkit v0.7.5/go.mod h1:+5hT6zhWGPEA2BQaq9i1WShdWPHWXbDNrQvfEQDWojQ=
github.com/dogmatiq/sqltest v0.3.0 h1:DCwyLWfVk/ZHsqq5Itq3H/Lqsh/CIQ6nIRwI4YLywFc=
github.com/dogmatiq/sqltest v0.3.0/go.mod h1:a8Da8NhU4m3lq5Sybhiv+ZQowSnGHWTIJHFNInVtffg=
github.com/dogmatiq/testkit v0.17.2 h1:WzXOc3p1u7CfboKSCJ/+H8Q9Bf9DKN1X+FKRqEi0DQ8=
github.com/dogmatiq/testkit v0.17.2/go.mod h1:6G6fknGE/B6pkPEYsP+rJskF6Drs9RnYBdjdEHBErWc=
github.com/dogmatiq/testkit v0.17.3-0.20240926003334-8aa7bdf0aec1 h1:TTVpXY2bNFg5wwk6m3JioVLoUrho4ZBbmhW111vzYtw=
github.com/dogmatiq/testkit v0.17.3-0.20240926003334-8aa7bdf0aec1/go.mod h1:r2ICPCX23WWQXGo9QCtYm61Rb7c7ljyZzz+q3PBKPw8=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand Down Expand Up @@ -289,10 +287,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand All @@ -318,3 +312,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
9 changes: 5 additions & 4 deletions messages/commands/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
)

Expand Down Expand Up @@ -86,7 +87,7 @@ func (m DebitAccount) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m OpenAccountForNewCustomer) Validate() error {
func (m OpenAccountForNewCustomer) Validate(dogma.CommandValidationScope) error {
if m.CustomerID == "" {
return errors.New("OpenAccountForNewCustomer must not have an empty customer ID")
}
Expand All @@ -104,7 +105,7 @@ func (m OpenAccountForNewCustomer) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m OpenAccount) Validate() error {
func (m OpenAccount) Validate(dogma.CommandValidationScope) error {
if m.CustomerID == "" {
return errors.New("OpenAccount must not have an empty customer ID")
}
Expand All @@ -119,7 +120,7 @@ func (m OpenAccount) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m CreditAccount) Validate() error {
func (m CreditAccount) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("CreditAccount must not have an empty transaction ID")
}
Expand All @@ -137,7 +138,7 @@ func (m CreditAccount) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m DebitAccount) Validate() error {
func (m DebitAccount) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("DebitAccount must not have an empty transaction ID")
}
Expand Down
3 changes: 2 additions & 1 deletion messages/commands/dailydebitlimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
"github.com/dogmatiq/example/messages/internal/validation"
)
Expand Down Expand Up @@ -31,7 +32,7 @@ func (m ConsumeDailyDebitLimit) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m ConsumeDailyDebitLimit) Validate() error {
func (m ConsumeDailyDebitLimit) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("ConsumeDailyDebitLimit must not have an empty transaction ID")
}
Expand Down
5 changes: 3 additions & 2 deletions messages/commands/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
)

Expand Down Expand Up @@ -42,7 +43,7 @@ func (m ApproveDeposit) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m Deposit) Validate() error {
func (m Deposit) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("Deposit must not have an empty transaction ID")
}
Expand All @@ -57,7 +58,7 @@ func (m Deposit) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m ApproveDeposit) Validate() error {
func (m ApproveDeposit) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("ApproveDeposit must not have an empty transaction ID")
}
Expand Down
7 changes: 4 additions & 3 deletions messages/commands/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
)

Expand Down Expand Up @@ -70,7 +71,7 @@ func (m DeclineTransfer) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m Transfer) Validate() error {
func (m Transfer) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("Transfer must not have an empty transaction ID")
}
Expand All @@ -91,7 +92,7 @@ func (m Transfer) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m ApproveTransfer) Validate() error {
func (m ApproveTransfer) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("ApproveTransfer must not have an empty transaction ID")
}
Expand All @@ -109,7 +110,7 @@ func (m ApproveTransfer) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m DeclineTransfer) Validate() error {
func (m DeclineTransfer) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("DeclineTransfer must not have an empty transaction ID")
}
Expand Down
7 changes: 4 additions & 3 deletions messages/commands/withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
)

Expand Down Expand Up @@ -63,7 +64,7 @@ func (m DeclineWithdrawal) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m Withdraw) Validate() error {
func (m Withdraw) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("Withdraw must not have an empty transaction ID")
}
Expand All @@ -78,7 +79,7 @@ func (m Withdraw) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m ApproveWithdrawal) Validate() error {
func (m ApproveWithdrawal) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("ApproveWithdrawal must not have an empty transaction ID")
}
Expand All @@ -93,7 +94,7 @@ func (m ApproveWithdrawal) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m DeclineWithdrawal) Validate() error {
func (m DeclineWithdrawal) Validate(dogma.CommandValidationScope) error {
if m.TransactionID == "" {
return errors.New("DeclineWithdrawal must not have an empty transaction ID")
}
Expand Down
9 changes: 5 additions & 4 deletions messages/events/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
)

Expand Down Expand Up @@ -87,7 +88,7 @@ func (m AccountDebitDeclined) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m AccountOpened) Validate() error {
func (m AccountOpened) Validate(dogma.EventValidationScope) error {
if m.CustomerID == "" {
return errors.New("AccountOpened must not have an empty customer ID")
}
Expand All @@ -102,7 +103,7 @@ func (m AccountOpened) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m AccountCredited) Validate() error {
func (m AccountCredited) Validate(dogma.EventValidationScope) error {
if m.TransactionID == "" {
return errors.New("AccountCredited must not have an empty transaction ID")
}
Expand All @@ -120,7 +121,7 @@ func (m AccountCredited) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m AccountDebited) Validate() error {
func (m AccountDebited) Validate(dogma.EventValidationScope) error {
if m.TransactionID == "" {
return errors.New("AccountDebited must not have an empty transaction ID")
}
Expand All @@ -138,7 +139,7 @@ func (m AccountDebited) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m AccountDebitDeclined) Validate() error {
func (m AccountDebitDeclined) Validate(dogma.EventValidationScope) error {
if m.TransactionID == "" {
return errors.New("AccountDebitDeclined must not have an empty transaction ID")
}
Expand Down
4 changes: 3 additions & 1 deletion messages/events/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package events
import (
"errors"
"fmt"

"github.com/dogmatiq/dogma"
)

// CustomerAcquired is an event indicating that a new customer has been
Expand All @@ -24,7 +26,7 @@ func (m CustomerAcquired) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m CustomerAcquired) Validate() error {
func (m CustomerAcquired) Validate(dogma.EventValidationScope) error {
if m.CustomerID == "" {
return errors.New("CustomerAcquired must not have an empty customer ID")
}
Expand Down
5 changes: 3 additions & 2 deletions messages/events/dailydebitlimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
"github.com/dogmatiq/example/messages/internal/validation"
)
Expand Down Expand Up @@ -57,7 +58,7 @@ func (m DailyDebitLimitExceeded) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m DailyDebitLimitConsumed) Validate() error {
func (m DailyDebitLimitConsumed) Validate(dogma.EventValidationScope) error {
if m.TransactionID == "" {
return errors.New("DailyDebitLimitConsumed must not have an empty transaction ID")
}
Expand Down Expand Up @@ -87,7 +88,7 @@ func (m DailyDebitLimitConsumed) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m DailyDebitLimitExceeded) Validate() error {
func (m DailyDebitLimitExceeded) Validate(dogma.EventValidationScope) error {
if m.TransactionID == "" {
return errors.New("DailyDebitLimitExceeded must not have an empty transaction ID")
}
Expand Down
5 changes: 3 additions & 2 deletions messages/events/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/example/messages"
)

Expand Down Expand Up @@ -44,7 +45,7 @@ func (m DepositApproved) MessageDescription() string {
}

// Validate returns a non-nil error if the message is invalid.
func (m DepositStarted) Validate() error {
func (m DepositStarted) Validate(dogma.EventValidationScope) error {
if m.TransactionID == "" {
return errors.New("DepositStarted must not have an empty transaction ID")
}
Expand All @@ -59,7 +60,7 @@ func (m DepositStarted) Validate() error {
}

// Validate returns a non-nil error if the message is invalid.
func (m DepositApproved) Validate() error {
func (m DepositApproved) Validate(dogma.EventValidationScope) error {
if m.TransactionID == "" {
return errors.New("DepositApproved must not have an empty transaction ID")
}
Expand Down
Loading

0 comments on commit 820c01d

Please sign in to comment.