Documentation ¶
Overview ¶
Package validator sets up several methods for simple validation as well as setting up an interface which when implemented allows for custom validation logic by the implementor. `Valid()` returns a boolean indicating if the value(s) passed into it are valid based on the different types. `Assert()` returns an error indicating `nil` if the values are valid. Otherwise `Assert()` returns an error indicating the index of the value(s) passed into it as to which was determined to be invalid.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
func Assert(objs ...interface{}) error
Assert determines the validity of each value passed in to determine if the inputs are valid. A non-nil error return indicates an invalid assertion and a nil error returns indicates validity
Types ¶
type ValidationError ¶
type ValidationError struct { // Message contains the custom message // for this validation error Message string // Index is the argument index which was // invalid during validation Index int // Type is the type of the invalid argument // at the index specified Type reflect.Type // ValidatorFailure indicates if the failure // was at the level which executes the Validate // method of a struct implementing the validator // interface which indicates it was in the users // validation logic where the failure occurred ValidatorFailure bool }
ValidationError is a custom error type for the validator library which provides additional information when using the Assert methods for validating input values. This error contains more information pertinent to what the errors were when attempting to validation the arguments.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Error implements the error interface for validation errors to be returned instead of standard lib errors
func (ValidationError) String ¶
func (e ValidationError) String() string
String implements the stringer interface so that the error can be properly printed by the fmt printers, etc...