From 820c01dfaf3dd54b2b091a3277f054118435bd45 Mon Sep 17 00:00:00 2001 From: James Harris Date: Thu, 26 Sep 2024 12:50:39 +1000 Subject: [PATCH] Update validation methods to accept validation scope arguments. --- domain/transfer.go | 2 +- go.mod | 13 ++++--------- go.sum | 24 ++++++++++-------------- messages/commands/account.go | 9 +++++---- messages/commands/dailydebitlimit.go | 3 ++- messages/commands/deposit.go | 5 +++-- messages/commands/transfer.go | 7 ++++--- messages/commands/withdrawal.go | 7 ++++--- messages/events/account.go | 9 +++++---- messages/events/customer.go | 4 +++- messages/events/dailydebitlimit.go | 5 +++-- messages/events/deposit.go | 5 +++-- messages/events/transfer.go | 7 ++++--- messages/events/withdrawal.go | 7 ++++--- 14 files changed, 55 insertions(+), 52 deletions(-) diff --git a/domain/transfer.go b/domain/transfer.go index acadcda..446d486 100644 --- a/domain/transfer.go +++ b/domain/transfer.go @@ -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") } diff --git a/go.mod b/go.mod index b524aef..6014dca 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 ) diff --git a/go.sum b/go.sum index f40ecee..b469d55 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= @@ -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= @@ -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= diff --git a/messages/commands/account.go b/messages/commands/account.go index 26c0e67..07211b8 100644 --- a/messages/commands/account.go +++ b/messages/commands/account.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -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") } @@ -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") } @@ -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") } @@ -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") } diff --git a/messages/commands/dailydebitlimit.go b/messages/commands/dailydebitlimit.go index aacdb2a..345326f 100644 --- a/messages/commands/dailydebitlimit.go +++ b/messages/commands/dailydebitlimit.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" "github.com/dogmatiq/example/messages/internal/validation" ) @@ -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") } diff --git a/messages/commands/deposit.go b/messages/commands/deposit.go index 78dfc76..fa95788 100644 --- a/messages/commands/deposit.go +++ b/messages/commands/deposit.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -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") } @@ -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") } diff --git a/messages/commands/transfer.go b/messages/commands/transfer.go index dce03d0..2a7eec5 100644 --- a/messages/commands/transfer.go +++ b/messages/commands/transfer.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -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") } @@ -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") } @@ -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") } diff --git a/messages/commands/withdrawal.go b/messages/commands/withdrawal.go index ad60996..d70c2ef 100644 --- a/messages/commands/withdrawal.go +++ b/messages/commands/withdrawal.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -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") } @@ -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") } @@ -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") } diff --git a/messages/events/account.go b/messages/events/account.go index 3d87e1c..1d3f75e 100644 --- a/messages/events/account.go +++ b/messages/events/account.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -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") } @@ -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") } @@ -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") } @@ -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") } diff --git a/messages/events/customer.go b/messages/events/customer.go index 0093dba..6285ff5 100644 --- a/messages/events/customer.go +++ b/messages/events/customer.go @@ -3,6 +3,8 @@ package events import ( "errors" "fmt" + + "github.com/dogmatiq/dogma" ) // CustomerAcquired is an event indicating that a new customer has been @@ -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") } diff --git a/messages/events/dailydebitlimit.go b/messages/events/dailydebitlimit.go index d83855e..e89fc82 100644 --- a/messages/events/dailydebitlimit.go +++ b/messages/events/dailydebitlimit.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" "github.com/dogmatiq/example/messages/internal/validation" ) @@ -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") } @@ -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") } diff --git a/messages/events/deposit.go b/messages/events/deposit.go index 605803d..73a9275 100644 --- a/messages/events/deposit.go +++ b/messages/events/deposit.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -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") } @@ -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") } diff --git a/messages/events/transfer.go b/messages/events/transfer.go index 8d58e95..79ae2b2 100644 --- a/messages/events/transfer.go +++ b/messages/events/transfer.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -72,7 +73,7 @@ func (m TransferDeclined) MessageDescription() string { } // Validate returns a non-nil error if the message is invalid. -func (m TransferStarted) Validate() error { +func (m TransferStarted) Validate(dogma.EventValidationScope) error { if m.TransactionID == "" { return errors.New("TransferStarted must not have an empty transaction ID") } @@ -93,7 +94,7 @@ func (m TransferStarted) Validate() error { } // Validate returns a non-nil error if the message is invalid. -func (m TransferApproved) Validate() error { +func (m TransferApproved) Validate(dogma.EventValidationScope) error { if m.TransactionID == "" { return errors.New("TransferApproved must not have an empty transaction ID") } @@ -114,7 +115,7 @@ func (m TransferApproved) Validate() error { } // Validate returns a non-nil error if the message is invalid. -func (m TransferDeclined) Validate() error { +func (m TransferDeclined) Validate(dogma.EventValidationScope) error { if m.TransactionID == "" { return errors.New("TransferDeclined must not have an empty transaction ID") } diff --git a/messages/events/withdrawal.go b/messages/events/withdrawal.go index 8521068..bd8b859 100644 --- a/messages/events/withdrawal.go +++ b/messages/events/withdrawal.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/dogmatiq/dogma" "github.com/dogmatiq/example/messages" ) @@ -66,7 +67,7 @@ func (m WithdrawalDeclined) MessageDescription() string { } // Validate returns a non-nil error if the message is invalid. -func (m WithdrawalStarted) Validate() error { +func (m WithdrawalStarted) Validate(dogma.EventValidationScope) error { if m.TransactionID == "" { return errors.New("WithdrawalStarted must not have an empty transaction ID") } @@ -81,7 +82,7 @@ func (m WithdrawalStarted) Validate() error { } // Validate returns a non-nil error if the message is invalid. -func (m WithdrawalApproved) Validate() error { +func (m WithdrawalApproved) Validate(dogma.EventValidationScope) error { if m.TransactionID == "" { return errors.New("WithdrawalApproved must not have an empty transaction ID") } @@ -96,7 +97,7 @@ func (m WithdrawalApproved) Validate() error { } // Validate returns a non-nil error if the message is invalid. -func (m WithdrawalDeclined) Validate() error { +func (m WithdrawalDeclined) Validate(dogma.EventValidationScope) error { if m.TransactionID == "" { return errors.New("WithdrawalDeclined must not have an empty transaction ID") }