Documentation ¶
Index ¶
Constants ¶
const ( // ContainerID defines the id to be used // as the container registration id of a validation. ContainerID = slaterest.ContainerID + ".validation" // ContainerUniversalTranslatorID defines the id to be used // as the container registration id of a universal translator. ContainerUniversalTranslatorID = ContainerID + ".universal_translator" // ContainerTranslatorID defines the id to be used // as the container registration id of a translator. ContainerTranslatorID = ContainerID + ".translator" // ContainerParserID defines the id to be used // as the container registration id of an error parser instance. ContainerParserID = ContainerID + ".parser" )
const ( // EnvID defines the slate.slaterest.validation package base environment variable name. EnvID = slaterest.EnvID + "_VALIDATION" )
Variables ¶
var ( // Locale defines the default locale string to be used when // instantiating the translator. Locale = senv.String(EnvID+"_LOCALE", "en") )
Functions ¶
func GetTranslator ¶
func GetTranslator(c slate.ServiceContainer) (ut.Translator, error)
GetTranslator will try to retrieve the registered translator instance from the application service container.
func GetUniversalTranslator ¶
func GetUniversalTranslator(c slate.ServiceContainer) (*ut.UniversalTranslator, error)
GetUniversalTranslator will try to retrieve the registered universal translator instance from the application service container.
Types ¶
type Parser ¶
type Parser interface { Parse(val interface{}, errs validator.ValidationErrors) (*srenvelope.Envelope, error) AddError(err string, code int) }
Parser defines the interface to an error parsing object used to convert a validation error into an envelope error
type Provider ¶
type Provider struct{}
Provider @todo doc
type Validator ¶
type Validator func(val interface{}) (*srenvelope.Envelope, error)
Validator is a function type used to define a calling interface of function responsible to validate an instance of a structure and return an initialized response envelope with the founded errors
func GetValidator ¶
func GetValidator(c slate.ServiceContainer) (Validator, error)
GetValidator will try to retrieve the registered validator instance from the application service container.
func NewValidator ¶
NewValidator instantiates a new validation function