Documentation
¶
Overview ¶
Package validation provides gin-kit validation implementation support.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = New()
Default is safe for concurrent validation after application startup.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// Field store data used by this type.
Field string
// Rule store data used by this type.
Rule string
// Parameter store data used by this type.
Parameter string
}
Context is supplied to message translators.
type Errors ¶
type Errors struct {
// Fields store data used by this type.
Fields map[string][]FieldError `json:"fields"`
}
Errors groups failures by their JSON field path.
type FieldError ¶
type FieldError struct {
// Rule store data used by this type.
Rule string `json:"rule"`
// Message store data used by this type.
Message string `json:"message"`
// Parameters store data used by this type.
Parameters map[string]string `json:"parameters"`
}
FieldError describes one failed validation rule without exposing the submitted value.
type Translator ¶
Translator converts a failed rule into a public, human-readable message.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is an explicit wrapper around go-playground/validator.
func New ¶
func New() *Validator
New creates a validator which reports JSON/form field names and English messages.
func (*Validator) RegisterMessage ¶
RegisterMessage overrides a message for a rule. The placeholders {field} and {parameter} are expanded when the error is rendered.
func (*Validator) RegisterRule ¶
RegisterRule registers an application-specific validation tag.
func (*Validator) SetTranslator ¶
func (v *Validator) SetTranslator(translator Translator)
SetTranslator replaces the default English translator.