Skip to content
Snippets Groups Projects
Commit c5a60050 authored by Dmitry Popov's avatar Dmitry Popov
Browse files

Merge branch 'develop-test' into 'main'

Refactoring add validation to WalletDebit and WalletCredit

See merge request !17
parents 4a0a048b d62d950f
No related branches found
Tags 0.8.2
1 merge request!17Refactoring add validation to WalletDebit and WalletCredit
......@@ -2,20 +2,26 @@ package wms
import (
"fmt"
"github.com/go-playground/validator/v10"
"github.com/google/uuid"
"gitlab.sessia.com/sdk/events"
)
type WalletDebit struct {
OwnerID uuid.UUID `json:"ownerId"`
Amount float64 `json:"amount"`
Description string `json:"description"`
OwnerID uuid.UUID `json:"ownerId" validate:"required"`
Amount float64 `json:"amount" validate:"required"`
Description string `json:"description" validate:"required"`
}
func (r *WalletDebit) GetEventName() string {
return events.EventNameWalletDebit
}
func (r *WalletDebit) Validate() error {
validate := validator.New()
return validate.Struct(r)
}
func (r *WalletDebit) IsRequest() bool {
return true
}
......@@ -44,15 +50,20 @@ func (r *WalletDebit) NewFromMap(dataMap map[string]interface{}) error {
}
type WalletCredit struct {
OwnerID uuid.UUID `json:"ownerId"`
Amount float64 `json:"amount"`
Description string `json:"description"`
OwnerID uuid.UUID `json:"ownerId" validate:"required"`
Amount float64 `json:"amount" validate:"required"`
Description string `json:"description" validate:"required"`
}
func (r *WalletCredit) GetEventName() string {
return events.EventNameWalletCredit
}
func (r *WalletCredit) Validate() error {
validate := validator.New()
return validate.Struct(r)
}
func (r *WalletCredit) IsRequest() bool {
return true
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment