Documentation ¶
Index ¶
- Variables
- func DoesNotMatchError(field_name, match_expression, actual string) error
- func FromEnvironment[T any](t *T) error
- func InvalidOptionError(value string, options []string) error
- func New[T any](options ...OptionsFunc[*T]) (*T, error)
- func RequiredError(tagname, tag_details string) error
- func Unmarshal(s any, options ...func(*Options)) (err error)
- func WithOptionsContext(ctx context.Context, options *Options) context.Context
- func WithTagContext(ctx context.Context, tag *Tag) context.Context
- type ContextKey
- type Duration
- type Middleware
- type Options
- type OptionsFunc
- type Tag
- func (t *Tag) Bytes() []byte
- func (t *Tag) Contents() string
- func (t *Tag) DefaultMiddleware() []Middleware
- func (t *Tag) GetState() map[string]interface{}
- func (t *Tag) GetStateValue(key string) interface{}
- func (t *Tag) Push(us ...Middleware)
- func (t *Tag) Read(p []byte) (n int, err error)
- func (tag *Tag) UnmarshalField(ctx context.Context, field reflect.StructField) (err error)
- func (t *Tag) UnmarshalText(text []byte) (err error)
- func (t *Tag) Write(p []byte) (n int, err error)
- type TagHandler
- type TagHandlerFunc
- type TagParser
- type TagUnmarshaler
Constants ¶
This section is empty.
Variables ¶
View Source
var INVALID_FIELD_ERROR = errors.New("invalid field value")
View Source
var INVALID_TAG_SYNTAX_ERROR = errors.New("invalid tag definition; tag syntax {tagvalue} (default={value}|options=[...comma seperated values]|required) ")
View Source
var NOT_UNMARSHALLABLE_ERROR = errors.New("field is not unmarshallable")
View Source
var TAG_VALIDATION_ERROR = errors.New("invalid field definition; no tag value or default")
Functions ¶
func DoesNotMatchError ¶ added in v0.0.3
func FromEnvironment ¶ added in v0.0.3
func InvalidOptionError ¶ added in v0.0.3
func New ¶
func New[T any](options ...OptionsFunc[*T]) (*T, error)
func RequiredError ¶ added in v0.0.3
func WithOptionsContext ¶ added in v0.0.4
Types ¶
type ContextKey ¶ added in v0.0.3
type ContextKey contextKey
type Duration ¶
Custom implementation for Parsing Durations from a string instead of parsing it as an int64
func (*Duration) UnmarshalText ¶ added in v0.0.3
type Middleware ¶ added in v0.0.3
type Middleware func(next TagHandler) TagHandler
func DefaultMiddleware ¶ added in v0.0.4
func DefaultMiddleware() []Middleware
type Options ¶ added in v0.0.4
type Options struct {
Middleware []Middleware
}
func GetOptionsContext ¶ added in v0.0.4
type OptionsFunc ¶
type Tag ¶
type Tag struct { FieldType string FieldName string Value reflect.Value Parent reflect.Value Name string Default string Content string Raw string Options []string Required bool Matcher *regexp.Regexp IgnoreNil bool Skip bool // contains filtered or unexported fields }
func MustGetTagContext ¶ added in v0.0.3
func NewTag ¶ added in v0.0.3
unmarshalling order 1. env 2. default 3. options 4. matches 5. required 6. zero values (default unmarshaller)
func (*Tag) DefaultMiddleware ¶ added in v0.0.4
func (t *Tag) DefaultMiddleware() []Middleware
func (*Tag) GetStateValue ¶ added in v0.0.4
func (*Tag) Push ¶ added in v0.0.4
func (t *Tag) Push(us ...Middleware)
func (*Tag) UnmarshalField ¶ added in v0.0.3
func (*Tag) UnmarshalText ¶ added in v0.0.4
type TagHandler ¶ added in v0.0.3
type TagHandler interface {
UnmarshalField(context.Context, reflect.StructField) error
}
func WithDefaultTag ¶ added in v0.0.3
func WithDefaultTag(next TagHandler) TagHandler
func WithEnvTag ¶ added in v0.0.3
func WithEnvTag(next TagHandler) TagHandler
func WithEnvyGlobalTag ¶ added in v0.0.4
func WithEnvyGlobalTag(next TagHandler) TagHandler
func WithMatchesTag ¶ added in v0.0.3
func WithMatchesTag(next TagHandler) TagHandler
func WithOptionsTag ¶ added in v0.0.3
func WithOptionsTag(next TagHandler) TagHandler
func WithRequiredTag ¶ added in v0.0.3
func WithRequiredTag(next TagHandler) TagHandler
type TagHandlerFunc ¶ added in v0.0.3
type TagHandlerFunc func(ctx context.Context, field reflect.StructField) error
func (TagHandlerFunc) UnmarshalField ¶ added in v0.0.3
func (f TagHandlerFunc) UnmarshalField(ctx context.Context, field reflect.StructField) error
type TagParser ¶ added in v0.0.3
type TagParser interface { TagName() string Handler() TagHandler }
type TagUnmarshaler ¶ added in v0.0.4
type TagUnmarshaler interface {
UnmarshalField(context.Context, reflect.StructField) error
}
Source Files ¶
- duration.go
- errors.go
- handler.go
- handler_default_tag.go
- handler_env_tag.go
- handler_envy_tag.go
- handler_matches_tag.go
- handler_options_tag.go
- handler_required_tag.go
- new.go
- options.go
- tag.go
- tag_context.go
- tag_type_defs.go
- unmarshal.go
- unmarshal_boolean.go
- unmarshal_float.go
- unmarshal_int.go
- unmarshal_pointer.go
- unmarshal_slice.go
- unmarshal_string.go
- unmarshal_struct.go
- unmarshal_uint.go
Click to show internal directories.
Click to hide internal directories.