-
Notifications
You must be signed in to change notification settings - Fork 1
/
bankenums.go
69 lines (56 loc) · 1.68 KB
/
bankenums.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package bank
import (
"database/sql/driver"
"fmt"
)
///////////////////////////////////////////////////////////////////////////////
// AccountType
// AccountType holds the type of a bank account.
// AccountType implements the database/sql.Scanner and database/sql/driver.Valuer interfaces,
// and will treat an empty string AccountType as SQL NULL value.
type AccountType string
var (
// AccountTypeCurrent is a checking account type
AccountTypeCurrent AccountType = "CURRENT"
// AccountTypeSavings is a savings account type
AccountTypeSavings AccountType = "SAVINGS"
)
func (t AccountType) Valid() bool {
return t == AccountTypeCurrent || t == AccountTypeSavings
}
// Scan implements the database/sql.Scanner interface.
func (t *AccountType) Scan(value any) error {
switch x := value.(type) {
case string:
*t = AccountType(x)
case []byte:
*t = AccountType(x)
case nil:
*t = ""
default:
return fmt.Errorf("can't scan SQL value of type %T as AccountType", value)
}
return nil
}
// Value implements the driver database/sql/driver.Valuer interface.
func (t AccountType) Value() (driver.Value, error) {
if t == "" {
return nil, nil
}
return string(t), nil
}
///////////////////////////////////////////////////////////////////////////////
// TransactionType
type TransactionType string
const (
TransactionTypeIncoming TransactionType = "INCOMING"
TransactionTypeOutgoing TransactionType = "OUTGOING"
)
///////////////////////////////////////////////////////////////////////////////
// PaymentStatus
type PaymentStatus string
const (
PaymentStatusCreated PaymentStatus = "CREATED"
PaymentStatusFinished PaymentStatus = "FINISHED"
PaymentStatusFailed PaymentStatus = "FAILED"
)