inputs

package
v0.0.0-...-f003305 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 18 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIDDecodeNotUUID - an error that tells caller the id is not a uuid
	ErrIDDecodeNotUUID = errors.New("failed to decode id: id is not a uuid")
	// ErrIDDecodeEmpty - an error that tells caller the id is empty and should not be
	ErrIDDecodeEmpty = errors.New("failed to decode id: id cannot be empty")
)
View Source
var (
	// ErrPublicKeyDecodeEmpty - an error that tells caller the public key is empty and should not be
	ErrPublicKeyDecodeEmpty = errors.New("failed to decode public key: public key cannot be empty")
)

Functions

func Decode

func Decode(ctx context.Context, d Decodable, input []byte) error

Decode - decode a decodable thing

func DecodeAndValidate

func DecodeAndValidate(ctx context.Context, v DecodeValidate, input []byte) error

DecodeAndValidate - perform decode and validate of input in one swipe

func DecodeAndValidateReader

func DecodeAndValidateReader(ctx context.Context, v DecodeValidate, input io.Reader) error

DecodeAndValidateReader - perform decode and validate of input in one swipe

func DecodeAndValidateString

func DecodeAndValidateString(ctx context.Context, v DecodeValidate, input string) error

DecodeAndValidateString - perform decode and validate of input in one swipe of a string input

func DecodeJSON

func DecodeJSON(ctx context.Context, input []byte, v interface{}) error

DecodeJSON - decode json helper

func Validate

func Validate(ctx context.Context, v Validatable) error

Validate - a validatable thing

Types

type Decodable

type Decodable interface {
	Decode(context.Context, []byte) error
}

Decodable - and interface that allows for validation of inputs and params

type DecodeValidate

type DecodeValidate interface {
	Validatable
	Decodable
}

DecodeValidate - decode and validate for inputs

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID - a generic ID type that can be used for common id based things

func (*ID) Decode

func (id *ID) Decode(ctx context.Context, input []byte) error

Decode - take raw []byte input and populate id with the ID

func (*ID) String

func (id *ID) String() string

String - return the String representation of the ID

func (*ID) UUID

func (id *ID) UUID() *uuid.UUID

UUID - return the UUID representation of the ID

func (*ID) Validate

func (id *ID) Validate(ctx context.Context) error

Validate - take raw []byte input and populate id with the ID

type MerchantID

type MerchantID struct {
	// contains filtered or unexported fields
}

MerchantID - identifier of a merchant

func NewMerchantID

func NewMerchantID(ctx context.Context, v string) (*MerchantID, error)

NewMerchantID - create a new merchant id

func (*MerchantID) Decode

func (m *MerchantID) Decode(ctx context.Context, v []byte) error

Decode - implementation of decodable interface

func (MerchantID) UUID

func (m MerchantID) UUID() uuid.UUID

UUID - get the UUID representation of the merchant id

func (*MerchantID) Validate

func (m *MerchantID) Validate(ctx context.Context) error

Validate - implementation of validatable interface

type OrderDirection

type OrderDirection string

OrderDirection - the directionality type

const (
	// Ascending - ASC
	Ascending OrderDirection = "ASC"
	// Descending - DESC
	Descending = "DESC"
)

type PageOrder

type PageOrder struct {
	Direction OrderDirection
	Attribute string
}

PageOrder - this directionality and attribute used for ordering

type Pagination

type Pagination struct {
	Order    []PageOrder
	RawOrder []string
	Page     int
	Items    int
}

Pagination - parameters common to pagination page=1&items=50&order=id

func NewPagination

func NewPagination(ctx context.Context, url string, v interface{}) (context.Context, *Pagination, error)

NewPagination - create a new Pagination struct and populate from url and order options

func (*Pagination) Decode

func (p *Pagination) Decode(ctx context.Context, v []byte) error

Decode - implementation of decodable interface

func (Pagination) GetOrderBy

func (p Pagination) GetOrderBy(ctx context.Context) string

GetOrderBy - create the order by expression and parameters for pagination

func (*Pagination) Validate

func (p *Pagination) Validate(ctx context.Context) error

Validate - implementation of validatable interface

type PublicKey

type PublicKey string

PublicKey - a generic ID type that can be used for common id based things

func (*PublicKey) Decode

func (pk *PublicKey) Decode(ctx context.Context, input []byte) error

Decode - take raw []byte input and populate id with the public key

func (*PublicKey) String

func (pk *PublicKey) String() string

String - return the String representation of the public key

func (*PublicKey) Validate

func (pk *PublicKey) Validate(ctx context.Context) error

Validate - take raw []byte input and populate public key with the value

type Validatable

type Validatable interface {
	Validate(context.Context) error
}

Validatable - and interface that allows for validation of inputs and params

Jump to

Keyboard shortcuts

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