config

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(c Config) error

Validate deeply validates the config based on the tags

Types

type Config

type Config struct {
	Version      string                    `yaml:"version" json:"version"`
	APIKey       string                    `yaml:"api_key" json:"api_key"`
	Schedule     string                    `yaml:"schedule" json:"schedule" validate:"cron"`
	Locations    []string                  `yaml:"locations" json:"locations"`
	Variables    variables.Variables       `yaml:"variables" json:"variables"`
	Transactions []transaction.Transaction `yaml:"transactions" json:"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 added in v0.1.6

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

type CronValidator added in v0.1.6

type CronValidator struct{}

func (CronValidator) Validate added in v0.1.6

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.

Jump to

Keyboard shortcuts

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