Documentation ¶
Index ¶
- Constants
- func IsValidatable(v interface{}) bool
- func MustRegisterValidator(tag string, validator validator.Func)
- func MustValidate(v interface{})
- func MustValidateStruct(v interface{})
- func NewErrFailedValidation(format string, fields map[string]interface{}, options ...errorz.Option) error
- func RegexpValidatorFactory(regexp *regexp.Regexp) validator.Func
- func Validate(v interface{}) error
- func ValidateStruct(v interface{}) error
- func WrapErrFailedValidation(err error, options ...errorz.Option) error
- type SimpleValidator
- type Validator
Constants ¶
View Source
const ( // ErrIDFailedValidation is an error ID. ErrIDFailedValidation = errorz.ID("failed-validation") )
Variables ¶
This section is empty.
Functions ¶
func IsValidatable ¶
func IsValidatable(v interface{}) bool
IsValidatable returns true if the given struct implements at least one of Validator or SimpleValidator.
func MustRegisterValidator ¶
func MustRegisterValidator(tag string, validator validator.Func)
MustRegisterValidator registers a validator.
func MustValidate ¶
func MustValidate(v interface{})
MustValidate is like Validate but panics on error.
func MustValidateStruct ¶
func MustValidateStruct(v interface{})
MustValidateStruct is like ValidateStruct, panics on error.
func NewErrFailedValidation ¶
func NewErrFailedValidation(format string, fields map[string]interface{}, options ...errorz.Option) error
NewErrFailedValidation creates a new failed validation error.
func RegexpValidatorFactory ¶
RegexpValidatorFactory creates a validator that matches a regexp.
Types ¶
type SimpleValidator ¶
type SimpleValidator interface {
Valid() bool
}
SimpleValidator describes a type that can validate itself, returning only a "valid" bool.
Click to show internal directories.
Click to hide internal directories.