Back to godoc.org

Package config

v0.3.2
Latest Go to latest
Published: Jul 9, 2020 | License: GPL3 | Module: github.com/getapid/apid-cli

Index

Package Files

func Validate

func Validate(c Config) error

Validate deeply validates the config based on the tags

type Config

type Config struct {
	Version      string                    `yaml:"version"`
	APIKey       string                    `yaml:"api_key"`
	Schedule     string                    `yaml:"schedule" validate:"cron"`
	Locations    []string                  `yaml:"locations"`
	Variables    variables.Variables       `yaml:"variables"`
	Transactions []transaction.Transaction `yaml:"transactions" validate:"unique=ID"`
}

Config holds the internal representation of the config. It has yaml tags to allow to marshalling

func Load

func Load(path string) (Config, error)

func LoadReader

func LoadReader(r io.Reader) (Config, error)

type CronValidator

type CronValidator struct{}

func (CronValidator) Validate

func (c CronValidator) Validate(val interface{}) (bool, error)

type DefaultValidator

type DefaultValidator struct {
}

DefaultValidator does not perform any validations.

func (DefaultValidator) Validate

func (v DefaultValidator) Validate(interface{}) (bool, error)

Validate method performs validation and returns result and optional error.

type ExpectBodyValidator

type ExpectBodyValidator struct{}

ExpectBodyValidator validates a step.ExpectBody so that the type and the exact fields make sense together. It also sets the defaults for type and exact

func (ExpectBodyValidator) Validate

func (v ExpectBodyValidator) Validate(val interface{}) (b bool, err error)

type RequiredValidator

type RequiredValidator struct{}

RequiredValidator validates slices and their length

func (RequiredValidator) Validate

func (v RequiredValidator) Validate(val interface{}) (b bool, err error)

Validate method performs validation and returns result and optional error.

type UniqueValidator

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

UniqueValidator validates all elements in the slice have unique property (defined by the prop)

func (UniqueValidator) Validate

func (v UniqueValidator) Validate(val interface{}) (b bool, err error)

Validate method performs validation and returns result and optional error.

type Validator

type Validator interface {
	// Validate method performs validation and returns result and optional error.
	Validate(interface{}) (bool, error)
}

Validator iterface for the different types to implement

type VersionValidator

type VersionValidator struct{}

VersionValidator validates string if it is a valid version

func (VersionValidator) Validate

func (v VersionValidator) Validate(val interface{}) (bool, error)

Validate method performs validation and returns result and optional error.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier