Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidUTF8 = errors.New("invalid utf-8 in string field") ErrInvalidMessageSource = errors.New("invalid message source") )
var Module = fx.Options( fx.Provide(utf8ValidatorProvider), )
Functions ¶
func Validate ¶
Validate maybe validates one proto message, depending on dynamic config and random sampling. If validation fails, this may still return no error, depending on dynamic config. This deliberately does not return a serviceerror because the decision of which serviceerror to use is contextual. The caller should wrap it in the appropriate serviceerror.
Types ¶
type MessageSource ¶
type MessageSource int
const ( SourceRPCRequest MessageSource = iota SourceRPCResponse SourcePersistence )
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
A Validator validates utf-8 in string fields of proto messages. The proto library normally does this automatically, but we disable it for now as part of migration from gogoproto, which did not validate. Eventually we'll remove this and enable it normally.
func (*Validator) Intercept ¶
func (v *Validator) Intercept(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)
Intercept acts as grpc interceptor.
func (*Validator) Validate ¶
Validate maybe validates one proto message, depending on dynamic config and random sampling. If validation fails, this may still return no error, depending on dynamic config. This deliberately does not return a serviceerror because the decision of which serviceerror to use is contextual. The caller should wrap it in the appropriate serviceerror.