func NewError(fieldViolations []*errdetails.BadRequest_FieldViolation) error
NewError creates a new validation error from the provided field violations.
Error represents a message validation error.
type Error struct {
// contains filtered or unexported fields
}
func (e *Error) Error() string
Error implements the error interface.
func (e *Error) GRPCStatus() *status.Status
GRPCStatus converts the validation error to a gRPC status with code INVALID_ARGUMENT.
MessageValidator provides primitives for validating the fields of a message.
type MessageValidator struct {
// contains filtered or unexported fields
}
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 (m *MessageValidator) AddFieldViolation(field, description string, formatArgs ...interface{})
AddFieldViolation adds a field violation to the message validator.
func (m *MessageValidator) Err() error
Err returns the validator's current validation error, or nil if no field validations have been registered.
func (m *MessageValidator) SetParentField(parentField string)
SetParentField sets a parent field which will be prepended to all the subsequently added violations.