Documentation
¶
Overview ¶
Package validator provides a framework for writing validations for Go data structures.
Index ¶
- type Errors
- func NewErrors() *Errors
- func NewErrorsP() *Errors
- func NewErrorsSync() *Errors
- func NewErrorsSyncP() *Errors
- func Validate(validators ...Validator) *Errors
- func ValidateP(validators ...Validator) *Errors
- func ValidateSync(validators ...Validator) *Errors
- func ValidateSyncP(validators ...Validator) *Errors
- func (e *Errors) Add(path string, msg string)
- func (e *Errors) Count() int
- func (e *Errors) Data() interface{}
- func (e *Errors) Error() string
- func (e *Errors) Exists(path string) bool
- func (e *Errors) Get(path string) []string
- func (e *Errors) HasAny() bool
- func (e *Errors) JSON() string
- func (e *Errors) Keys() []string
- func (e *Errors) Lookup(prefix string) map[string][]string
- func (e *Errors) Raw() json.RawMessage
- func (e *Errors) Validate(validators ...Validator)
- func (e *Errors) ValidateS(validators ...Validator)
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
Errors describes custom validator errors object.
func NewErrors ¶
func NewErrors() *Errors
NewErrors returns a pointer to an initialized Errors object with dot notated JSON disabled (no nested struct).
func NewErrorsP ¶
func NewErrorsP() *Errors
NewErrorsP returns a pointer to an initialized Errors object with dot notated JSON enabled (nested struct).
func NewErrorsSync ¶
func NewErrorsSync() *Errors
NewErrorsSync returns a pointer to an initialized Errors object with dot notated JSON disabled (no nested struct). Validations will run in single goroutine.
func NewErrorsSyncP ¶
func NewErrorsSyncP() *Errors
NewErrorsSyncP returns a pointer to an initialized Errors object with dot notated JSON enabled (nested struct). Validations will run in single goroutine.
func ValidateSync ¶
ValidateSync wraps Validate method with dot notated JSON disabled. Validations will run in single goroutine.
func ValidateSyncP ¶
ValidateSyncP wraps Validate method with dot notated JSON enabled. Validations will run in single goroutine.
func (*Errors) Add ¶
Add will add (append) a new error message to the list of errors using the given path.
func (*Errors) Exists ¶
Exists returns 'true' if given path exist and has errors, else returns 'false'.
func (*Errors) HasAny ¶
HasAny returns 'true' if errors have occurred, 'false' if no errors occurred.
func (*Errors) Raw ¶
func (e *Errors) Raw() json.RawMessage
Raw returns JSON formatted errors (as json.RawMessage).
type Validator ¶
type Validator interface {
Validate(e *Errors)
}
Validator must be implemented in order to pass the validator object into the Validate function.
func ValidateFunc ¶
ValidateFunc wraps any function in a 'Validator' for custom validator rules.
Directories
¶
Path | Synopsis |
---|---|
_examples
|
|
Package validators contains built-in validators for parent package "github.com/s3rj1k/validator"
|
Package validators contains built-in validators for parent package "github.com/s3rj1k/validator" |