Documentation
¶
Index ¶
- Constants
- Variables
- type Generator
- type JSONGenerator
- type Logger
- type Mapper
- func (m *Mapper) AddFieldNestedMapper(fieldName string, nestedMapper *Mapper)
- func (m *Mapper) AddFieldTagName(fieldName, fieldTagName string)
- func (m *Mapper) GetFieldNestedMapper(fieldName string) *Mapper
- func (m *Mapper) GetFieldTagName(fieldName string) (string, bool)
- func (m *Mapper) GetFieldsTagName() *map[string]string
- func (m *Mapper) GetNestedMappers() *map[string]*Mapper
- func (m *Mapper) GetRequiredFields() *map[string]bool
- func (m *Mapper) GetStructInstance() interface{}
- func (m *Mapper) HasFieldsValidations() bool
- func (m *Mapper) IsFieldRequired(fieldName string) (bool, bool)
- func (m *Mapper) SetFieldIsRequired(fieldName string, required bool)
- func (m *Mapper) Type() reflect.Type
- type ProtobufGenerator
Constants ¶
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 ¶
var ( ErrNilGenerator = errors.New("generator cannot be nil") ErrNilMapper = errors.New("mapper cannot be nil") ErrProtobufTagNotFound = "missing protobuf tag: %s" ErrProtobufTagNameNotFound = "missing protobuf tag name: %s" ErrEmptyJSONTag = "empty json tag: %s" )
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator interface { NewMapper(structInstance interface{}) (*Mapper, error) NewMapperWithNoError(structInstance interface{}) *Mapper }
Generator is an interface for creating a mapper
type JSONGenerator ¶
type JSONGenerator struct {
// contains filtered or unexported fields
}
JSONGenerator is a generator for JSON mappers
func NewJSONGenerator ¶
func NewJSONGenerator(logger *Logger) *JSONGenerator
NewJSONGenerator creates a new JSON generator
func (*JSONGenerator) NewMapper ¶
func (j *JSONGenerator) NewMapper(structInstance interface{}) ( *Mapper, error, )
NewMapper creates the fields to validate from a JSON struct
func (*JSONGenerator) NewMapperWithNoError ¶ added in v0.5.21
func (j *JSONGenerator) NewMapperWithNoError(structInstance interface{}) *Mapper
NewMapperWithNoError creates the fields to validate from a JSON struct
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the JWT validator logger
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper is a map of fields to validate from a struct
func (*Mapper) AddFieldNestedMapper ¶
AddFieldNestedMapper adds a nested mapper to the mapper
func (*Mapper) AddFieldTagName ¶
AddFieldTagName adds a field tag name to the mapper
func (*Mapper) GetFieldNestedMapper ¶
GetFieldNestedMapper returns the nested mapper of a field
func (*Mapper) GetFieldTagName ¶
GetFieldTagName returns the tag name of a field
func (*Mapper) GetFieldsTagName ¶
GetFieldsTagName returns the fields of the mapper
func (*Mapper) GetNestedMappers ¶
GetNestedMappers returns the nested mappers of the mapper
func (*Mapper) GetRequiredFields ¶
GetRequiredFields returns the required fields of the mapper
func (*Mapper) GetStructInstance ¶
func (m *Mapper) GetStructInstance() interface{}
GetStructInstance returns the instance of the struct
func (*Mapper) HasFieldsValidations ¶
HasFieldsValidations returns if the mapper has fields
func (*Mapper) IsFieldRequired ¶
IsFieldRequired returns if a field is required
func (*Mapper) SetFieldIsRequired ¶
SetFieldIsRequired sets if a field is required
type ProtobufGenerator ¶
type ProtobufGenerator struct {
// contains filtered or unexported fields
}
ProtobufGenerator is a generator for Protobuf mappers
func NewProtobufGenerator ¶
func NewProtobufGenerator(logger *Logger) *ProtobufGenerator
NewProtobufGenerator creates a new Protobuf generator
func (*ProtobufGenerator) NewMapper ¶
func (p *ProtobufGenerator) NewMapper(structInstance interface{}) ( *Mapper, error, )
NewMapper creates the fields to validate from a Protobuf compiled struct
func (*ProtobufGenerator) NewMapperWithNoError ¶ added in v0.5.21
func (p *ProtobufGenerator) NewMapperWithNoError(structInstance interface{}) *Mapper
NewMapperWithNoError creates the fields to validate from a Protobuf compiled struct