mapper

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	State              = "state"
	SizeCache          = "sizeCache"
	UnknownFields      = "unknownFields"
	ProtobufTag        = "protobuf"
	ProtobufOneOf      = "oneof"
	ProtobufNamePrefix = "name="
	JSONTag            = "json"
	JSONOmitempty      = "omitempty"
)

Protobuf fields generated by the protoc compiler

Variables

View Source
var (
	ErrProtobufTagNotFound     = "missing protobuf tag: %s"
	ErrProtobufTagNameNotFound = "missing protobuf tag name: %s"
	ErrEmptyJSONTag            = "empty json tag: %s"
)

Functions

This section is empty.

Types

type Generator added in v0.3.0

type Generator interface {
	NewMapper(structInstance interface{}) (*Mapper, error)
}

Generator is an interface for creating a mapper

type JSONGenerator added in v0.3.0

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

JSONGenerator is a generator for JSON mappers

func NewJSONGenerator added in v0.3.0

func NewJSONGenerator(logger *Logger) *JSONGenerator

NewJSONGenerator creates a new JSON generator

func (*JSONGenerator) NewMapper added in v0.3.0

func (j *JSONGenerator) NewMapper(structInstance interface{}) (
	*Mapper,
	error,
)

NewMapper creates the fields to validate from a JSON struct

type Logger added in v0.4.6

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

Logger is the JWT validator logger

func NewLogger added in v0.4.6

func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error)

NewLogger creates a new JWT validator logger

func (*Logger) DetectedField added in v0.5.5

func (l *Logger) DetectedField(
	structTypeName string,
	fieldName string,
	fieldType reflect.Type,
	tag string,
	required bool,
)

DetectedField prints a detected field

type Mapper

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

Mapper is a map of fields to validate from a struct

func NewMapper added in v0.5.5

func NewMapper(structInstance interface{}) *Mapper

NewMapper creates a new mapper

func (*Mapper) AddFieldNestedMapper added in v0.5.5

func (m *Mapper) AddFieldNestedMapper(fieldName string, nestedMapper *Mapper)

AddFieldNestedMapper adds a nested mapper to the mapper

func (*Mapper) AddFieldTagName added in v0.5.13

func (m *Mapper) AddFieldTagName(fieldName, fieldTagName string)

AddFieldTagName adds a field tag name to the mapper

func (*Mapper) GetFieldNestedMapper added in v0.5.5

func (m *Mapper) GetFieldNestedMapper(fieldName string) *Mapper

GetFieldNestedMapper returns the nested mapper of a field

func (*Mapper) GetFieldTagName added in v0.5.13

func (m *Mapper) GetFieldTagName(fieldName string) (
	string,
	bool,
)

GetFieldTagName returns the tag name of a field

func (*Mapper) GetFieldsTagName added in v0.5.13

func (m *Mapper) GetFieldsTagName() *map[string]string

GetFieldsTagName returns the fields of the mapper

func (*Mapper) GetNestedMappers added in v0.5.5

func (m *Mapper) GetNestedMappers() *map[string]*Mapper

GetNestedMappers returns the nested mappers of the mapper

func (*Mapper) GetRequiredFields added in v0.5.13

func (m *Mapper) GetRequiredFields() *map[string]bool

GetRequiredFields returns the required fields of the mapper

func (*Mapper) GetStructInstance added in v0.5.9

func (m *Mapper) GetStructInstance() interface{}

GetStructInstance returns the instance of the struct

func (*Mapper) HasFieldsValidations added in v0.5.5

func (m *Mapper) HasFieldsValidations() bool

HasFieldsValidations returns if the mapper has fields

func (*Mapper) IsFieldRequired added in v0.5.13

func (m *Mapper) IsFieldRequired(fieldName string) (bool, bool)

IsFieldRequired returns if a field is required

func (*Mapper) SetFieldIsRequired added in v0.5.13

func (m *Mapper) SetFieldIsRequired(fieldName string, required bool)

SetFieldIsRequired sets if a field is required

func (*Mapper) Type added in v0.5.9

func (m *Mapper) Type() reflect.Type

Type returns the type of the struct instance

type ProtobufGenerator added in v0.3.0

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

ProtobufGenerator is a generator for Protobuf mappers

func NewProtobufGenerator added in v0.3.0

func NewProtobufGenerator(logger *Logger) *ProtobufGenerator

NewProtobufGenerator creates a new Protobuf generator

func (*ProtobufGenerator) NewMapper added in v0.3.0

func (p *ProtobufGenerator) NewMapper(structInstance interface{}) (
	*Mapper,
	error,
)

NewMapper creates the fields to validate from a Protobuf compiled struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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