Skip to content

Commit

Permalink
added bank.NullableBIC.Normalized and NormalizedOrNull
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Aug 22, 2024
1 parent bb4e5c4 commit 3b45a40
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bank/nullablebic.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ func (bic NullableBIC) Validate() error {
return BIC(bic).Validate()
}

func (bic NullableBIC) Normalized() (NullableBIC, error) {
if bic.IsNull() {
return bic, nil
}
normalized, err := BIC(bic).Normalized()
if err != nil {
return bic, err
}
return NullableBIC(normalized), nil
}

func (bic NullableBIC) NormalizedOrNull() NullableBIC {
normalized, err := bic.Normalized()
if err != nil {
return BICNull
}
return normalized
}

// Scan implements the database/sql.Scanner interface.
func (bic *NullableBIC) Scan(value any) error {
switch x := value.(type) {
Expand Down

0 comments on commit 3b45a40

Please sign in to comment.