| 83 | } |
| 84 | |
| 85 | func (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 | |
| 99 | func (b *CreateBalanceMonitor) ValidateCreateBalanceMonitor() error { |
| 100 | return validation.ValidateStruct(b, |