Documentation ¶
Index ¶
Constants ¶
const ( // ContainerID defines the id to be used as the default of a // validator instance in the application container. ContainerID = "gapp.rest.validation" // ContainerUniversalTranslatorID defines the id to be used // as the default of error message universal translator in the // application container. ContainerUniversalTranslatorID = ContainerID + ".universal-translator" // ContainerTranslatorID defines the id to be used // as the default of error message translator in the application container. ContainerTranslatorID = ContainerID + ".translator" // ContainerParserID defines the id to be used // as the default of an error parser instance in the application container. ContainerParserID = ContainerID + ".parser" // ContainerValidatorID defines the id to be used // as the default of a validator instance in the application container. ContainerValidatorID = ContainerID + ".validator" // EnvLocale defines the name of the environment variable // to be checked for an overriding value for the validation error // parser translation local. EnvLocale = "GAPP_REST_VALIDATION_LOCAL" )
Variables ¶
var ( // Locale defines the default locale string to be used when // instantiating the error parser translator. Locale = "en" )
Functions ¶
func NewProvider ¶
NewProvider will create a new validation provider instance
Types ¶
type Parser ¶
type Parser interface {
Parse(ctx *gin.Context, val interface{}, errs validator.ValidationErrors) envelope.Envelope
}
Parser defines the interface to a error parsing class used to convert a validation error into a envelope error
func NewParser ¶
func NewParser(trans ut.Translator) Parser
NewParser instantiate a new validation parser instance
type ParserStrategy ¶
type ParserStrategy func(ctx *gin.Context, val interface{}, err validator.FieldError) envelope.Error
ParserStrategy is a function type used to define a calling interface of a function responsible to parse a validation error into an envelope error information
func NewParserStrategy ¶
func NewParserStrategy(trans ut.Translator) ParserStrategy
NewParserStrategy instantiate a new default error parser strategy used by the parser to convert a validation error into a envelope error
type Validator ¶
Validator is a function type used to define a calling interface of function responsible to validate an instance of a structure and return a initialized response envelope with the founded errors
func NewValidator ¶
NewValidator instantiates a new validation function