input

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InputTypeString   = "string"
	InputTypePassword = "password"
	InputTypeBool     = "bool"
	InputTypeNumber   = "number"
)

accepted input types

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Regex       *string       `json:"regex,omitempty"`
	LegalValues []interface{} `json:"legal_values,omitempty"`
	Collection  bool          `json:"collection"`
	Type        string        `json:"type,omitempty"`
	Optional    bool          `json:"optional"`
	Default     interface{}   `json:"default"`
}

Input represents a single input for a task it can express constraints on the acceptable values, such as a type (string by default), a regexp to be matched, an enumeration of legal values, wether a collection of values is accepted instead of a single value, and wether the input is altogether optional, which can be supported with a default value

func (Input) CheckValue

func (i Input) CheckValue(val interface{}) error

CheckValue verifies an input's constraints against a concrete value

func (Input) Valid

func (i Input) Valid() error

Valid asserts that an input definition is valid - a regexp and a legal_values list are mutually exclusive - a regexp must compile - the input's type must be among the accepted types defined above - legal_values must match the declared type - default value must match the declared type

Jump to

Keyboard shortcuts

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