validate

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityValidator

type EntityValidator interface {
	Validate(interface{}) *Result
}

An EntityValidator is an interface for things that can validate entities

type HeaderValidator

type HeaderValidator struct {
	KnownFormats strfmt.Registry
	// contains filtered or unexported fields
}

A HeaderValidator has very limited subset of validations to apply

func NewHeaderValidator

func NewHeaderValidator(name string, header *spec.Header, formats strfmt.Registry) *HeaderValidator

NewHeaderValidator creates a new header validator object

func (*HeaderValidator) Validate

func (p *HeaderValidator) Validate(data interface{}) *Result

Validate the value of the header against its schema

type ParamValidator

type ParamValidator struct {
	KnownFormats strfmt.Registry
	// contains filtered or unexported fields
}

A ParamValidator has very limited subset of validations to apply

func NewParamValidator

func NewParamValidator(param *spec.Parameter, formats strfmt.Registry) *ParamValidator

NewParamValidator creates a new param validator object

func (*ParamValidator) Validate

func (p *ParamValidator) Validate(data interface{}) *Result

Validate the data against the description of the parameter

type Result

type Result struct {
	Errors     []error
	MatchCount int
}

Result represents a validation result

func (*Result) AddErrors

func (r *Result) AddErrors(errors ...error)

AddErrors adds errors to this validation result

func (*Result) AsError

func (r *Result) AsError() error

func (*Result) HasErrors

func (r *Result) HasErrors() bool

HasErrors returns true when this result is invalid

func (*Result) Inc

func (r *Result) Inc()

Inc increments the match count

func (*Result) IsValid

func (r *Result) IsValid() bool

IsValid returns true when this result is valid

func (*Result) Merge

func (r *Result) Merge(other *Result) *Result

Merge merges this result with the other one, preserving match counts etc

type SchemaValidator

type SchemaValidator struct {
	Path string

	Schema *spec.Schema

	Root         interface{}
	KnownFormats strfmt.Registry
	// contains filtered or unexported fields
}

SchemaValidator like param validator but for a full json schema

func NewSchemaValidator

func NewSchemaValidator(schema *spec.Schema, rootSchema interface{}, root string, formats strfmt.Registry) *SchemaValidator

NewSchemaValidator creates a new schema validator

func (*SchemaValidator) Applies

func (s *SchemaValidator) Applies(source interface{}, kind reflect.Kind) bool

Applies returns true when this schema validator applies

func (*SchemaValidator) SetPath

func (s *SchemaValidator) SetPath(path string)

SetPath sets the path for this schema valdiator

func (*SchemaValidator) Validate

func (s *SchemaValidator) Validate(data interface{}) *Result

Validate validates the data against the schema

type SpecValidator

type SpecValidator struct {
	KnownFormats strfmt.Registry
	// contains filtered or unexported fields
}

SpecValidator validates a swagger spec

func NewSpecValidator

func NewSpecValidator(schema *spec.Schema, formats strfmt.Registry) *SpecValidator

NewSpecValidator creates a new swagger spec validator instance

func (*SpecValidator) Validate

func (s *SpecValidator) Validate(data interface{}) (errs *Result, warnings *Result)

Validate validates the swagger spec

Jump to

Keyboard shortcuts

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