stakeholder

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 CheckCNPJ

func CheckCNPJ(cnpj string) error

CheckCNPJ validates the given CNPJ

func CheckCPF

func CheckCPF(cpf string) error

CheckCPF validates the given CPF

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

func TypeText

func TypeText(t Type) string

TypeText returns the stakeholder type as a text

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

type Type

type Type int

Type is a strong type to classify a Stakeholder

const (

	// TypeUnknown is the default value, and usually means an error
	TypeUnknown Type = iota
	// TypePerson is used to represent 'Pessoa Fisica'
	TypePerson
	// TypeCompany is used to represent 'Pessoa Juridica'
	TypeCompany
)

func GetType

func GetType(s Stakeholder) Type

GetType returns the stakeholder type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL