Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidType is returned when the a Stakeholder has invalid Type value ErrInvalidType = errors.New("invalid stakeholder type") // ErrCPFInvalidLength is returned when a CPF has the wrong size ErrCPFInvalidLength = errors.New("cpf has invalid length") // ErrCPFEmpty is returned when CPF is empty ErrCPFEmpty = errors.New("cpf has empty value") // ErrCPFValidationDigit is returned when either of the validation digit is not valid ErrCPFValidationDigit = errors.New("cpf has wrong validation digit") // ErrCPFNotDigitsOnly is returned when CPF has any char that is not a number ErrCPFNotDigitsOnly = errors.New("cpf must be numbers only") // ErrCNPJInvalidLength is returned when a CNPJ has the wrong size ErrCNPJInvalidLength = errors.New("cnpj has invalid length") // ErrCNPJEmpty is returned when CPF is empty ErrCNPJEmpty = errors.New("cnpj has empty value") // ErrCNPJValidationDigit is returned when either of the validation digit is not valid ErrCNPJValidationDigit = errors.New("cnpj has wrong validation digit") // ErrCNPJNotDigitsOnly is returned when CNPJ has any char that is not a number ErrCNPJNotDigitsOnly = errors.New("cnpj must be numbers only") )
Functions ¶
func GetCPFCNPJ ¶
func GetCPFCNPJ(s Stakeholder) (cpf, cnpj string)
GetCPFCNPJ returns the CPF or CNPJ of the given stakeholder. Since a stakeholder cannot have both, one of them will be returned empty, or both if stakeholder is of unknown type
Types ¶
type Stakeholder ¶
type Stakeholder string
Stakeholder is used to represent a person or company involved in the resources of the system, interested in it's results.
func NewCNPJ ¶
func NewCNPJ(cnpj string) (Stakeholder, error)
NewCNPJ creates a new stakeholder with TypeCompany
func NewCPF ¶
func NewCPF(cpf string) (Stakeholder, error)
NewCPF creates a new stakeholder with TypePerson
func Parse ¶
func Parse(s string) (Stakeholder, error)
Parse attempts to create a stakeholder from it's ID
func (Stakeholder) MarshalJSON ¶
func (s Stakeholder) MarshalJSON() ([]byte, error)
MarshalJSON serializes the stakeholder value as a JSON value
func (Stakeholder) MarshalZerologObject ¶
func (s Stakeholder) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements the zerolog marshaler so it can be logged using: log.With().EmbededObject(stakeholder).Msg("Some message")
func (Stakeholder) String ¶
func (s Stakeholder) String() string
func (*Stakeholder) UnmarshalJSON ¶
func (s *Stakeholder) UnmarshalJSON(b []byte) error
UnmarshalJSON deserializes a JSON value into a Stakeholder value