validation

package
v0.0.0-...-95a70fc Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package validation exposes members to ease the validation process. It is based upon the excellent go-playground/valdator.v9 package.

Index

Constants

View Source
const FailedErrCode = "ValidationFailed"

FailedErrCode error code constant for validation errors.

Variables

View Source
var Validator = validator.New()

Validator instance exposed just in case you need more control over validation.

Functions

This section is empty.

Types

type Chain

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

Chain represents a validation facility to ease the validation process by providing a Fluent like API.

func Validate

func Validate(resource string) *Chain

Validate instantiate a new validation chain for the given resource. Then, you can use a fluent like API to constructs your validations and call Errors() to actually evaluates the chain.

func (*Chain) Errors

func (chain *Chain) Errors() error

Errors evaluates the entire chain and returns any errors as a DomainError containing FieldError as inner errors.

func (*Chain) Field

func (chain *Chain) Field(name string, value interface{}, tag string) *Chain

Field adds a validation for the given field name.

func (*Chain) FieldWithValue

func (chain *Chain) FieldWithValue(name string, value interface{}, other interface{}, tag string) *Chain

FieldWithValue adds a validation against another value to the chain.

type FieldError

type FieldError struct {
	Resource string `json:"resource"`
	Field    string `json:"field"`
	Code     string `json:"code"`
}

FieldError represents a field error that has occured during the validation step.

func (*FieldError) Error

func (err *FieldError) Error() string

Jump to

Keyboard shortcuts

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