entity

package
v0.0.0-...-eb9f5a9 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PGConstraintUniqueTokenAndTokenDate = "idx_unq_tokens_token_token_date"
)
View Source
const (
	PGErrCodeUniqueViolation = "23505"
)

Variables

View Source
var (
	ErrInputValidation       = fmt.Errorf("validation input error")
	ErrDuplicateTokenPerDate = fmt.Errorf("duplicate token generated in current date")
)

Functions

func GenerateID

func GenerateID() string

GenerateID generates a unique ID that can be used as an identifier for an entity.

Types

type InputGenerate

type InputGenerate struct {
	CustomerID string `json:"customer_id" validate:"required,numeric,startswith=62,min=10"`
}

InputGenerate .

type InputPutToken

type InputPutToken struct {
	CustomerID string `json:"customer_id" validate:"required,numeric,startswith=62,min=10"`
	Token      string `json:"token" validate:"required"`
}

PutToken

type InputValidate

type InputValidate struct {
	Token string `json:"token" validate:"required"`
}

InputValidate .

type Metadata

type Metadata struct {
	ValidatedAt time.Time `json:"validated_at"`
}

func (*Metadata) Scan

func (m *Metadata) Scan(src interface{}) error

Scan stores the src in *m. No validation is done.

func (Metadata) Value

func (m Metadata) Value() (driver.Value, error)

Value returns m as a value. This does a validating unmarshal into another RawMessage. If m is invalid json, it returns an error.

type OutGenerate

type OutGenerate struct {
	Token      string    `json:"token"`
	ValidUntil time.Time `json:"valid_until"`
}

OutGenerate .

type OutValidate

type OutValidate struct {
	Token       string    `json:"token"`
	CustomerID  string    `json:"customer_id"`
	ValidUntil  time.Time `json:"valid_until"`
	IsExpired   bool      `json:"is_expired"`
	IsValidated bool      `json:"is_validated"`
}

OutValidate .

type PayToken

type PayToken struct {
	ID         string    `db:"id" validate:"required,uuid"`
	Token      string    `db:"token" validate:"required,max=10"`
	TokenDate  time.Time `db:"token_date" validate:"required"`
	CustomerID string    `db:"customer_id" validate:"required"`
	ValidUntil time.Time `db:"valid_until" validate:"required"`
	CreatedAt  time.Time `db:"created_at" validate:"required"`
	UpdatedAt  time.Time `db:"updated_at" validate:"required"`
	Metadata   Metadata  `db:"metadata" validate:"-"`
}

PayToken struct is defined here

func NewToken

func NewToken() *PayToken

type User

type User struct {
	ID   string
	Name string
}

User represents a user.

func (User) GetID

func (u User) GetID() string

GetID returns the user ID.

func (User) GetName

func (u User) GetName() string

GetName returns the user name.

Jump to

Keyboard shortcuts

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