Documentation ¶
Overview ¶
*
- This package is the grpc validator with go-playground validator version 9.
- See that page for the details.
- https://github.com/go-playground/validator
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContextWithLocale ¶
NewContextWithLocale creates new context with locale
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(v *Validator) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns validator server interceptor for every request. If the request cannot be validated, the client gets the error with codes.FailedCondition If the request is nil, then this interceptor does nothing. If multiple languages are supported and should be different from each request, then the context which is generated by NewContextWithLocale should be passed before this interceptor.
Types ¶
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates struct with translated messages
func NewValidator ¶
func NewValidator(vOpts ...ValidatorOptions) (*Validator, error)
NewValidator returns Validator
func (*Validator) RegisterValidationCtx ¶
func (v *Validator) RegisterValidationCtx(tag string, fn validatorv9.FuncCtx) error
RegisterValidationCtx applies go-playground/validator.v9/Validate.RegisterValidationCtx
type ValidatorOptions ¶
type ValidatorOptions func(o *validatorOptions)
ValidatorOptions is the options for NewValidator function
func WithRegisterDefaultTranslationFunc ¶
func WithRegisterDefaultTranslationFunc(localePrefix string, registerDefaultTranslationFunc registerTranslationFunc) ValidatorOptions
WithTranslators returns the option to set translation functions for locales matching with localePrefix
func WithTranslators ¶
func WithTranslators(fallbackTranslator locales.Translator, localeTranslators ...locales.Translator) ValidatorOptions
WithTranslators returns the option for locale translators