customer

package
v0.0.0-...-8c0919e Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTypeNotEqual = errors.New("Type not equal")
)

Functions

func NewRandomID

func NewRandomID() uint32

func NewValidator

func NewValidator() *validator.Validate

func ValidateBeforeNow

func ValidateBeforeNow(fl validator.FieldLevel) bool

func ValidateDate

func ValidateDate(field reflect.Value) interface{}

func ValidateOrgName

func ValidateOrgName(fl validator.FieldLevel) bool

func ValidatePersonName

func ValidatePersonName(fl validator.FieldLevel) bool

Types

type Customer

type Customer struct {
	ID    uint32 `validate:"required"`
	State State  `validate:"min=1,max=3"`
	Info  `validate:"required"`
}

func New

func New(id uint32, i Info) *Customer

func NewWithRandomID

func NewWithRandomID(i Info) *Customer

func (*Customer) UpdateInfo

func (c *Customer) UpdateInfo(i Info) error

type CustomerType

type CustomerType int32
const (
	Private CustomerType = iota + 1
	Organization
)

type Info

type Info interface {
	Type() CustomerType
}

type OrganizationInfo

type OrganizationInfo struct {
	Name                string    `validate:"org-name"`
	Form                string    `validate:"required"`
	LeagalID            string    `validate:"required"`
	RegistrationDate    date.Date `validate:"required,before"`
	RegistrationCountry string    `validate:"required,iso3166_1_alpha2"`
}

func (*OrganizationInfo) Type

func (oi *OrganizationInfo) Type() CustomerType

type PersonInfo

type PersonInfo struct {
	GivenName   string    `validate:"person-name"`
	FamilyName  string    `validate:"person-name"`
	SSN         string    `validate:"required"`
	DateOfBirth date.Date `validate:"required,before"`
	Citizenship string    `validate:"required,iso3166_1_alpha2"`
}

func (*PersonInfo) Type

func (pi *PersonInfo) Type() CustomerType

type State

type State int32
const (
	Prospect State = iota + 1
	Active
	Passive
)

Jump to

Keyboard shortcuts

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