mapper

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: GPL-3.0 Imports: 5 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 (
	ErrMissingProtobufTag                 = "missing protobuf tag: %s"
	ErrMissingProtobufTagName             = "missing protobuf tag name: %s"
	ErrDuplicateProtobufTagName           = "duplicate protobuf tag name: %s"
	ErrMissingJSONTag                     = "missing json tag: %s"
	ErrMissingJSONTagLooksLikeProtocField = "missing json tag, looks like a protoc field: %s. If it is a protoc field, use ProtobufGenerator instead"
	ErrEmptyJSONTag                       = "empty json tag: %s"
	ErrDuplicateJSONTagName               = "duplicate json tag name: %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) PrintField added in v0.4.6

func (l *Logger) PrintField(
	structName string,
	fieldName string,
	fieldType reflect.Type,
)

PrintField prints a field

type Mapper

type Mapper struct {
	// Fields key is the field name and value is the name used in the validation error
	Fields map[string]string

	// NestedMappers key is the field name of the nested struct and value is the nested mapper
	NestedMappers map[string]*Mapper
}

Mapper is a map of fields to validate from a struct

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