Documentation
¶
Index ¶
- Variables
- type DefaultService
- func (d *DefaultService) Birthdate(birthdateField string, birthdate *time.Time, ...) error
- func (d *DefaultService) CreateValidateFn(mapper *govalidatormapper.Mapper, auxiliaryValidatorFn interface{}) (func(dest interface{}) (interface{}, error), error)
- func (d *DefaultService) Email(emailField string, email string, ...) error
- func (d *DefaultService) ParseValidations(rootStructValidations *govalidatormappervalidation.StructValidations) (interface{}, error)
- func (d *DefaultService) ValidateRequiredFields(rootStructValidations *govalidatormappervalidation.StructValidations, ...) error
- type DefaultValidator
- type Logger
- func (l *Logger) FieldTagNameNotFound(structTypeName, fieldName string, fieldType reflect.Type, ...)
- func (l *Logger) InitializedField(structTypeName, fieldName string, fieldType reflect.Type, ...)
- func (l *Logger) UninitializedField(structTypeName, fieldName string, fieldType reflect.Type, required bool)
- type Service
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilService = errors.New("mapper validator service cannot be nil") ErrNilDestination = errors.New("destination cannot be nil") ErrDestinationNotPointer = errors.New("destination must be a pointer") ErrNilMapper = errors.New("mapper cannot be nil") ErrNilValidator = errors.New("mapper validator cannot be nil") ErrFieldTagNameNotFound = "field tag name not found: %s" ErrFieldIsRequiredNotFound = "field is required not found: %s" ErrRequiredField = "%s is required" )
Functions ¶
This section is empty.
Types ¶
type DefaultService ¶
type DefaultService struct {
// contains filtered or unexported fields
}
DefaultService struct
func NewDefaultService ¶
func NewDefaultService( parser govalidatormapperparser.Parser, validator Validator, ) (*DefaultService, error)
NewDefaultService creates a new default validator service
func (*DefaultService) Birthdate ¶ added in v0.5.26
func (d *DefaultService) Birthdate( birthdateField string, birthdate *time.Time, validations *govalidatormappervalidation.StructValidations, ) error
Birthdate validates the birthdate field
func (*DefaultService) CreateValidateFn ¶ added in v0.5.24
func (d *DefaultService) CreateValidateFn( mapper *govalidatormapper.Mapper, auxiliaryValidatorFn interface{}, ) ( func( dest interface{}, ) (interface{}, error), error, )
CreateValidateFn creates a validate function for the request body using the validator functions provided. It validates the required fields by default
The auxiliary validator function should have the following signature:
func(dest *RequestType, validations *govalidatormappervalidation.StructValidations) error
func (*DefaultService) Email ¶ added in v0.5.26
func (d *DefaultService) Email( emailField string, email string, validations *govalidatormappervalidation.StructValidations, ) error
Email validates the email address field
func (*DefaultService) ParseValidations ¶
func (d *DefaultService) ParseValidations( rootStructValidations *govalidatormappervalidation.StructValidations, ) (interface{}, error)
ParseValidations parses the validations
func (*DefaultService) ValidateRequiredFields ¶
func (d *DefaultService) ValidateRequiredFields( rootStructValidations *govalidatormappervalidation.StructValidations, mapper *govalidatormapper.Mapper, ) error
ValidateRequiredFields validates the required fields
type DefaultValidator ¶
type DefaultValidator struct {
// contains filtered or unexported fields
}
DefaultValidator struct
func NewDefaultValidator ¶
func NewDefaultValidator( logger *Logger, ) *DefaultValidator
NewDefaultValidator creates a new default mapper validator
func (*DefaultValidator) IsFieldInitialized ¶
func (d *DefaultValidator) IsFieldInitialized( fieldValue reflect.Value, ) (isInitialized bool)
IsFieldInitialized checks if a field is initialized
func (*DefaultValidator) ValidateRequiredFields ¶
func (d *DefaultValidator) ValidateRequiredFields( rootStructValidations *govalidatormappervalidations.StructValidations, mapper *govalidatormapper.Mapper, ) error
ValidateRequiredFields validates the required fields of a struct
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the structs mapper validator logger
func NewLogger ¶
func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error)
NewLogger creates a new structs mapper validator logger
func (*Logger) FieldTagNameNotFound ¶ added in v0.5.15
func (l *Logger) FieldTagNameNotFound( structTypeName, fieldName string, fieldType reflect.Type, fieldValue interface{}, )
FieldTagNameNotFound prints the field tag name not found on debug mode
type Service ¶
type Service interface {
ValidateRequiredFields(
rootStructValidations *govalidatormappervalidation.StructValidations,
mapper *govalidatormapper.Mapper,
) error
ParseValidations(rootStructValidations *govalidatormappervalidation.StructValidations) (
interface{},
error,
)
Email(
emailField string,
email string,
validations *govalidatormappervalidation.StructValidations,
) error
Birthdate(
birthdateField string,
birthdate *time.Time,
validations *govalidatormappervalidation.StructValidations,
) error
CreateValidateFn(
mapper *govalidatormapper.Mapper,
auxiliaryValidatorFn interface{},
) (
func(
dest interface{},
) (interface{}, error), error,
)
}
Service interface for the validator service
type Validator ¶
type Validator interface {
ValidateRequiredFields(
rootStructValidations *govalidatormappervalidations.StructValidations,
mapper *govalidatormapper.Mapper,
) (err error)
}
Validator interface