Documentation
¶
Index ¶
- Variables
- func ArrayDeleteEmpties(s []string, keepSpaces bool) []string
- func FlatMergeMapStringInterface(base, changes map[string]interface{}) (result map[string]interface{}, err error)
- func GetAndUnsetEnv(key string) (result string, err error)
- func LookupEnvVar(key string) (value string)
- func ReadFile(file string) string
- func RegisterValidators(validators []Validator, v *validator.Validate, trans ut.Translator)
- func RegisterValidatorsDefault(validators []Validator)
- func StringJoinWithoutEmpties(stringss []string, sep string, keepSpaces bool) string
- func StructToMapStringInterface(structt interface{}) (result map[string]interface{})
- func UnmarshalTestValue(t *testing.T, jsonInput string, value interface{})
- func UpcaseFirstStrict(s string) string
- type CanBeValidated
- type Validator
- type ValidatorsCreatorFunc
Constants ¶
This section is empty.
Variables ¶
var ( // Translator provides a [ut.Translator] instance Translator ut.Translator // StructValidator provides a [validator.Validate] instance StructValidator *validator.Validate )
Functions ¶
func ArrayDeleteEmpties ¶
ArrayDeleteEmpties removes empty elements from a string array and returns a new array with the cleaned result.
Setting keepSpaces will not trim elements before checking for deletion
func FlatMergeMapStringInterface ¶
func FlatMergeMapStringInterface(base, changes map[string]interface{}) (result map[string]interface{}, err error)
FlatMergeMapStringInterface logically takes the base and merge changes onto it. Deletion is done by explicitly setting a field's empty value. Nil is kept, so it could be set, explicitly. For more sophisticated merging, use a library like https://github.com/imdario/mergo
func GetAndUnsetEnv ¶
GetAndUnsetEnv is following the security pattern DeleteOnFirstUse when it comes to reading environment variables.
So the environment variable is read once and gets deleted
func LookupEnvVar ¶
LookupEnvVar returns the value of an environment variable if it exists, without caring about if the variable itself was defined or not.
func RegisterValidators ¶
func RegisterValidators(validators []Validator, v *validator.Validate, trans ut.Translator)
RegisterValidators helps to register [Validator]s with provided translations and validations
func RegisterValidatorsDefault ¶
func RegisterValidatorsDefault(validators []Validator)
RegisterValidatorsDefault allows registering validators and are held within this library
func StringJoinWithoutEmpties ¶
StringJoinWithoutEmpties joins elements of an array after deleting empty elements. For deleting empty array elements ArrayDeleteEmpties is used
func StructToMapStringInterface ¶
func StructToMapStringInterface(structt interface{}) (result map[string]interface{})
StructToMapStringInterface turns a given struct to a map[string]interface{}
func UnmarshalTestValue ¶
UnmarshalTestValue takes a jsonInput and a proper struct type as value and tries to unmarshal the JSON to the struct
func UpcaseFirstStrict ¶
UpcaseFirstStrict takes a string and only sets first letter to upcase
Types ¶
type CanBeValidated ¶
type CanBeValidated interface {
Validate() error
}
CanBeValidated describes a type that can be validated
type ValidatorsCreatorFunc ¶
type ValidatorsCreatorFunc func(in CanBeValidated) []Validator
ValidatorsCreatorFunc describes a signature for functions that should be able to create [Validator]s