rules

package
v0.0.0-...-478f1f1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2016 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(tag string, method ValidatorFunc) (err error)

Add a new validation method for a given struct tag. If a validation method already exists this will return an error

Types

type ErrInvalid

type ErrInvalid struct {
	ValidationData
	Failure string
	Message string
}

func (ErrInvalid) Error

func (t ErrInvalid) Error() string

type ErrNoValidationMethod

type ErrNoValidationMethod struct {
	Tag string
}

func (ErrNoValidationMethod) Error

func (t ErrNoValidationMethod) Error() string

type ValidationData

type ValidationData struct {
	// The name of the field being validated
	Field string

	// The override message for validation failure
	Message string

	// The value of the struct field being validated
	Value interface{}

	// Arguments from the validation tags. For example, in the following
	// definition Args will will contain a single "5":
	//
	// struct {
	//     Age `validate:"GreaterThan:5"`
	// }
	//
	// Unfortunately, due to the nature of tags these will always be strings.
	Args []string
}

type ValidatorFunc

type ValidatorFunc func(ValidationData) error

All validation methods must return an ErrInvalid error type if the data is invalid, or nil if the data is valid

func Get

func Get(tag string) (method ValidatorFunc, err error)

Return a registered validation method for a given tag

Jump to

Keyboard shortcuts

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