gody: github.com/guiferpa/gody Index | Files | Directories

package gody

import "github.com/guiferpa/gody"


Package Files

rule.go serialize.go tag.go validate.go validator.go


const DefaultTagName = "validate"

func DefaultValidate Uses

func DefaultValidate(b interface{}, customRules []Rule) (bool, error)

func RawDefaultValidate Uses

func RawDefaultValidate(b interface{}, tn string, customRules []Rule) (bool, error)

func RawValidate Uses

func RawValidate(b interface{}, tn string, rules []Rule) (bool, error)

func Validate Uses

func Validate(b interface{}, rules []Rule) (bool, error)

Validate contains the entrypoint to validation of struct input

func ValidateFields Uses

func ValidateFields(fields []Field, rules []Rule) (bool, error)

type ErrDuplicatedRule Uses

type ErrDuplicatedRule struct {
    RuleDuplicated Rule

func (*ErrDuplicatedRule) Error Uses

func (err *ErrDuplicatedRule) Error() string

type ErrEmptyTagName Uses

type ErrEmptyTagName struct{}

func (*ErrEmptyTagName) Error Uses

func (e *ErrEmptyTagName) Error() string

type ErrInvalidBody Uses

type ErrInvalidBody struct {
    Kind reflect.Kind

ErrInvalidBody represents all invalid body report

func (*ErrInvalidBody) Error Uses

func (e *ErrInvalidBody) Error() string

type ErrInvalidTag Uses

type ErrInvalidTag struct {
    Format string

ErrInvalidTag represents all invalid tag report

func (*ErrInvalidTag) Error Uses

func (e *ErrInvalidTag) Error() string

type Field Uses

type Field struct {
    Name  string
    Value string
    Tags  map[string]string

Field is a struct to represents the domain about a field inner gody lib

func RawSerialize Uses

func RawSerialize(tn string, b interface{}) ([]Field, error)

RawSerialize is a func to serialize/parse all content about the struct input

func Serialize Uses

func Serialize(b interface{}) ([]Field, error)

type Rule Uses

type Rule interface {
    Name() string
    Validate(name, value, param string) (bool, error)

Rule is a interface with the contract to implement a any rule

type Validator Uses

type Validator struct {
    // contains filtered or unexported fields

func NewValidator Uses

func NewValidator() *Validator

func (*Validator) AddRules Uses

func (v *Validator) AddRules(rs ...Rule) error

func (*Validator) SetTagName Uses

func (v *Validator) SetTagName(tn string) error

func (*Validator) Validate Uses

func (v *Validator) Validate(b interface{}) (bool, error)



Package gody imports 4 packages (graph) and is imported by 1 packages. Updated 2020-11-23. Refresh now. Tools for package owners.