File size: 495 Bytes
fea99b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package currencyx

import (
	"errors"
	"fmt"

	"github.com/invopop/gobl/currency"
)

var _ fmt.Stringer = (*Code)(nil)

// Code represents a fiat or custom currency code. Code values used directly as
// Currency values are treated as fiat currencies for backwards compatibility.
type Code currency.Code

func (c Code) String() string {
	return string(c)
}

func (c Code) Validate() error {
	if c == "" {
		return errors.New("currency code is required")
	}

	return currency.Code(c).Validate()
}