map_validator

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoData            = errors.New("no validatorType")
	ErrInvalidJsonFormat = errors.New("is not valid json")
	ErrUnsupportType     = errors.New("type is not support")
)

Functions

func NewValidateBuilder

func NewValidateBuilder() *ruleState

func SetMessage added in v0.0.18

func SetMessage(msg string) *string

func SetTotal added in v0.0.7

func SetTotal(total int64) *int64

Types

type ChainResultType added in v0.0.31

type ChainResultType interface {
	GetAllKeys() []string
	PrintHierarchyWithSeparator(separator string, currentPath string)
	ToMap() map[string]interface{}
	RunManipulator() error
	RunUniqueChecker()
	GetErrors() []error
}

type ChainerType added in v0.0.31

type ChainerType interface {
	GetParentKey() string
	Next(index int) ChainerType
	Back() ChainerType
	Forward(index int) ChainerType
	SetKey(name string) ChainerType
	GetKey() string
	SetKeyValue(key string, value interface{}) ChainerType
	GetParentKeys() []string
	AddChild() ChainerType
	LoadFromMap(data map[string]interface{})
	SetValue(value interface{}) ChainerType
	GetValue() interface{}
	SetManipulator(manipulator *func(interface{}) (interface{}, error)) ChainerType
	SetUniques(uniques []string) ChainerType
	SetCustomMsg(customMsg *CustomMsg) ChainerType
	GetUniques() []string
	AddError(err error) ChainerType
	GetResult() ChainResultType

	GetChildren() []ChainerType
	GetParent() ChainerType
	GetBrothers() []ChainerType
}

type CustomMsg

type CustomMsg struct {
	OnTypeNotMatch *string
	//OnEnumValueNotMatch *string
	//OnNull              *string
	OnMax         *string
	OnMin         *string
	OnRegexString *string
	OnUnique      *string
}

type EnumField

type EnumField[T any] struct {
	Items               T
	StringCaseSensitive bool // will support soon
}

type ExtensionType added in v0.0.20

type ExtensionType interface {
	SetRoles(rules RulesWrapper)
	BeforeLoad(data interface{}) error
	AfterLoad(data *map[string]interface{}) error
	BeforeValidation(data *map[string]interface{}) error
	AfterValidation(data *map[string]interface{}) error
	SetExtraData(data *ExtraOperationData) ExtensionType
}

type ExtraOperationData added in v0.0.20

type ExtraOperationData struct {
	// contains filtered or unexported fields
}

func (*ExtraOperationData) Bind added in v0.0.20

func (state *ExtraOperationData) Bind(i interface{}) error

func (*ExtraOperationData) GetData added in v0.0.20

func (state *ExtraOperationData) GetData() map[string]interface{}

func (*ExtraOperationData) GetFilledField added in v0.0.20

func (state *ExtraOperationData) GetFilledField() []string

func (*ExtraOperationData) GetNullField added in v0.0.20

func (state *ExtraOperationData) GetNullField() []string

type ExtraOperationType added in v0.0.20

type ExtraOperationType interface {
	Bind(i interface{}) error
	GetFilledField() []string
	GetNullField() []string
	GetData() map[string]interface{}
}

type FileRequest

type FileRequest struct {
	File     multipart.File
	FileInfo *multipart.FileHeader
}

type MessageMeta added in v0.0.18

type MessageMeta struct {
	Field             *string
	ExpectedType      *reflect.Kind
	ActualLength      *int64
	ExpectedMinLength *int64
	ExpectedMaxLength *int64
	ActualType        *reflect.Kind
	UniqueOrigin      *string
	UniqueTarget      *string
}

type Rules

type Rules struct {
	Null               bool
	NilIfNull          bool
	AnonymousObject    bool
	Email              bool
	Enum               *EnumField[any]
	Type               reflect.Kind
	Max                *int64
	Min                *int64
	IfNull             interface{}
	UUID               bool
	UUIDToString       bool
	IPV4               bool
	IPV4Network        bool
	IPv4OptionalPrefix bool
	File               bool
	RegexString        string
	Unique             []string

	RequiredWithout []string
	RequiredIf      []string
	Object          *RulesWrapper
	ListObject      *RulesWrapper

	CustomMsg CustomMsg // will support soon
}

type RulesWrapper added in v0.0.22

type RulesWrapper struct {
	Rules   map[string]Rules
	Setting Setting
	// contains filtered or unexported fields
}

func BuildRoles added in v0.0.31

func BuildRoles() *RulesWrapper

func (*RulesWrapper) Done added in v0.0.31

func (rw *RulesWrapper) Done() RulesWrapper

func (*RulesWrapper) SetFieldsManipulator added in v0.0.34

func (rw *RulesWrapper) SetFieldsManipulator(fields []string, fun func(data interface{}) (result interface{}, err error)) *RulesWrapper

func (*RulesWrapper) SetManipulator added in v0.0.31

func (rw *RulesWrapper) SetManipulator(field string, fun func(data interface{}) (result interface{}, err error)) *RulesWrapper

func (*RulesWrapper) SetRule added in v0.0.31

func (rw *RulesWrapper) SetRule(field string, rule Rules) *RulesWrapper

func (*RulesWrapper) SetSetting added in v0.0.34

func (rw *RulesWrapper) SetSetting(setting Setting) *RulesWrapper

type Setting added in v0.0.22

type Setting struct {
	Strict bool
}

func BuildSetting added in v0.0.34

func BuildSetting() *Setting

func (*Setting) Done added in v0.0.34

func (s *Setting) Done() Setting

func (*Setting) MakeStrict added in v0.0.34

func (s *Setting) MakeStrict() *Setting

Jump to

Keyboard shortcuts

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