validator

package
v0.0.0-...-cfbe396 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoField is returned when a field could not be found
	ErrNoField = errors.New("no field found")

	// ErrFieldRequired is returned when a field is required
	ErrFieldRequired = errors.New("field is required")
)

Functions

This section is empty.

Types

type ValidationError

type ValidationError struct {
	Err error
}

ValidationError is returned when a value is not valid. This does look a little unnecessary, but it's useful to be able to distinguish errors we should present to the user versus errors that should just be in the logs

func (*ValidationError) Error

func (v *ValidationError) Error() string

type Validator

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

Validator validates values

func New

func New(s *app.Schema) *Validator

New returns a new Validator

func (*Validator) Field

func (v *Validator) Field(name string) (*app.Field, error)

Field returns the named field

func (*Validator) ValidateAll

func (v *Validator) ValidateAll(values map[string]interface{}) map[string]error

ValidateAll validates all the values in the fields, erroring on any extra

func (*Validator) ValidateField

func (v *Validator) ValidateField(name string, value interface{}) error

ValidateField validates a single field against the schema contained therein

Jump to

Keyboard shortcuts

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