Documentation ¶
Overview ¶
Package validation provides primitives for validating proto messages and gRPC requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewError ¶
func NewError(fieldViolations []*errdetails.BadRequest_FieldViolation) error
NewError creates a new validation error from the provided field violations.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a message validation error.
func (*Error) GRPCStatus ¶
GRPCStatus converts the validation error to a gRPC status with code INVALID_ARGUMENT.
type MessageValidator ¶
type MessageValidator struct {
// contains filtered or unexported fields
}
MessageValidator provides primitives for validating the fields of a message.
func (*MessageValidator) AddFieldError ¶
func (m *MessageValidator) AddFieldError(field string, err error)
AddFieldError adds a field violation from the provided error. If the provided error is a validation.Error, the individual field violations from the provided error are added.
func (*MessageValidator) AddFieldViolation ¶
func (m *MessageValidator) AddFieldViolation(field, description string, formatArgs ...interface{})
AddFieldViolation adds a field violation to the message validator.
func (*MessageValidator) Err ¶
func (m *MessageValidator) Err() error
Err returns the validator's current validation error, or nil if no field validations have been registered.
func (*MessageValidator) SetParentField ¶
func (m *MessageValidator) SetParentField(parentField string)
SetParentField sets a parent field which will be prepended to all the subsequently added violations.