validation

package
v4.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: Apache-2.0 Imports: 5 Imported by: 15

Documentation

Index

Constants

View Source
const (
	KeyDefault          = "default"
	KeyExamples         = "examples"
	KeyDescription      = "description"
	KeyTitle            = "title"
	KeyType             = "type"
	KeyConst            = "const"
	KeyEnum             = "enum"
	KeyMultipleOf       = "multipleOf"
	KeyMaximum          = "maximum"
	KeyMinimum          = "minimum"
	KeyExclusiveMaximum = "exclusiveMaximum"
	KeyExclusiveMinimum = "exclusiveMinimum"
	KeyMaxLength        = "maxLength"
	KeyMinLength        = "minLength"
	KeyPattern          = "pattern"
	KeyMaxItems         = "maxItems"
	KeyMinItems         = "minItems"
	KeyMaxProperties    = "maxProperties"
	KeyMinProperties    = "minProperties"
	KeyRequired         = "required"
	KeyPropertyNames    = "propertyNames"
)

Variables

This section is empty.

Functions

func ValidateStruct

func ValidateStruct(s interface{}) error

ValidateStruct executes the validation tags on a struct and returns any failures.

Types

type ConstraintBuilder

type ConstraintBuilder map[string]interface{}

A builder for JSON Schema compliant constraint lists

func NewConstraintBuilder

func NewConstraintBuilder() ConstraintBuilder
NewConstraintBuilder creates a builder for JSON Schema compliant constraint

lists. See http://json-schema.org/latest/json-schema-validation.html for types of validation available.

func (ConstraintBuilder) Build

func (cb ConstraintBuilder) Build() map[string]interface{}

func (ConstraintBuilder) Const

func (cb ConstraintBuilder) Const(value interface{}) ConstraintBuilder

Const adds a constraint that the field must equal this value.

func (ConstraintBuilder) Description

func (cb ConstraintBuilder) Description(desc string) ConstraintBuilder

Description adds a human-readable description

func (ConstraintBuilder) Enum

func (cb ConstraintBuilder) Enum(value ...interface{}) ConstraintBuilder

Enum adds a constraint that the field must be one of these values.

func (ConstraintBuilder) Examples

func (cb ConstraintBuilder) Examples(ex ...interface{}) ConstraintBuilder

Examples adds one or more examples

func (ConstraintBuilder) ExclusiveMaximum

func (cb ConstraintBuilder) ExclusiveMaximum(value int) ConstraintBuilder

ExclusiveMaximum adds a constraint that the field must be less than this number.

func (ConstraintBuilder) ExclusiveMinimum

func (cb ConstraintBuilder) ExclusiveMinimum(value int) ConstraintBuilder

ExclusiveMinimum adds a constraint that the field must be greater than this number.

func (ConstraintBuilder) MaxItems

func (cb ConstraintBuilder) MaxItems(value int) ConstraintBuilder

MaxItems adds a constraint that the array must have at most this many items.

func (ConstraintBuilder) MaxLength

func (cb ConstraintBuilder) MaxLength(value int) ConstraintBuilder

MaxLength adds a constraint that the string field must have at most this many characters.

func (ConstraintBuilder) MaxProperties

func (cb ConstraintBuilder) MaxProperties(value int) ConstraintBuilder

KeyMaxProperties adds a constraint that the object must have at most this many keys.

func (ConstraintBuilder) Maximum

func (cb ConstraintBuilder) Maximum(value int) ConstraintBuilder

Maximum adds a constraint that the field must be less than or equal to this number.

func (ConstraintBuilder) MinItems

func (cb ConstraintBuilder) MinItems(value int) ConstraintBuilder

MinItems adds a constraint that the array must have at least this many items.

func (ConstraintBuilder) MinLength

func (cb ConstraintBuilder) MinLength(value int) ConstraintBuilder

MinLength adds a constraint that the string field must have at least this many characters.

func (ConstraintBuilder) MinProperties

func (cb ConstraintBuilder) MinProperties(value int) ConstraintBuilder

MinProperties adds a constraint that the object must have at least this many keys.

func (ConstraintBuilder) Minimum

func (cb ConstraintBuilder) Minimum(value int) ConstraintBuilder

Minimum adds a constraint that the field must be greater than or equal to this number.

func (ConstraintBuilder) MultipleOf

func (cb ConstraintBuilder) MultipleOf(value int) ConstraintBuilder

MultipleOf adds a constraint that the field must be a multiple of this integer.

func (ConstraintBuilder) Pattern

func (cb ConstraintBuilder) Pattern(value string) ConstraintBuilder

Pattern adds a constraint that the string must match the given pattern.

func (ConstraintBuilder) PropertyNames

func (cb ConstraintBuilder) PropertyNames(properties map[string]interface{}) ConstraintBuilder

PropertyNames adds a constraint that the object property names must match the given schema.

func (ConstraintBuilder) Required

func (cb ConstraintBuilder) Required(properties ...string) ConstraintBuilder

Required adds a constraint that the object must have at least these keys.

func (ConstraintBuilder) Title

func (cb ConstraintBuilder) Title(title string) ConstraintBuilder

Title adds a human-readable label suitable for labeling a UI element.

func (ConstraintBuilder) Type

Type adds a type constrinat.

Jump to

Keyboard shortcuts

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