MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / ValidateCreateBalance

Method ValidateCreateBalance

api/model/model.go:85–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83}
84
85func (b *CreateBalance) ValidateCreateBalance() error {
86 // Normalize allocation strategy: trim and uppercase
87 if b.AllocationStrategy != "" {
88 b.AllocationStrategy = strings.TrimSpace(strings.ToUpper(b.AllocationStrategy))
89 }
90
91 return validation.ValidateStruct(b,
92 validation.Field(&b.LedgerId, validation.Required),
93 validation.Field(&b.Currency, validation.Required),
94 validation.Field(&b.IdentityId, validation.When(b.TrackFundLineage, validation.Required.Error("identity_id is required when track_fund_lineage is enabled"))),
95 validation.Field(&b.AllocationStrategy, validation.When(b.AllocationStrategy != "", validation.In("FIFO", "LIFO", "PROPORTIONAL").Error("allocation_strategy must be one of: FIFO, LIFO, PROPORTIONAL"))),
96 )
97}
98
99func (b *CreateBalanceMonitor) ValidateCreateBalanceMonitor() error {
100 return validation.ValidateStruct(b,

Callers 2

CreateBalanceMethod · 0.95

Calls 1

ErrorMethod · 0.45

Tested by 1