userver: grpc_protovalidate::ValidationError Class Reference
Loading...
Searching...
No Matches
grpc_protovalidate::ValidationError Class Reference

Detailed Description

Definition at line 20 of file validate.hpp.

Public Types

enum class  Type {
  kInternal = 1 ,
  kRule = 2
}
 Type of validation error. More...
 

Public Member Functions

 ValidationError (Type type, std::string description, std::string message_name)
 
 ValidationError (buf::validate::ValidationResult result, std::string message_name)
 Creates an error of type Type::kRule.
 
Type GetType () const
 Get error type.
 
const std::string & GetMessageName () const
 A fully-qualified name of the message type this error originates from.
 
const std::string & GetDescription () const
 A human-readable description of the error.
 
const std::vector< buf::validate::RuleViolation > & GetViolations () const
 A list of found contraint violations.
 
grpc::Status GetGrpcStatus (bool include_violations=true) const
 Constructs a grpc::Status of this error.
 

Member Enumeration Documentation

◆ Type

Type of validation error.

Enumerator
kInternal 

Validation failed due to validator internal errors. In most cases this indicates protovalidate CEL expression errors in the proto file.

kRule 

Validation failed due to violations of protovalidate constraints by the input message.

Definition at line 23 of file validate.hpp.

Constructor & Destructor Documentation

◆ ValidationError() [1/2]

grpc_protovalidate::ValidationError::ValidationError ( Type  type,
std::string  description,
std::string  message_name 
)

Definition at line 31 of file validate.cpp.

◆ ValidationError() [2/2]

grpc_protovalidate::ValidationError::ValidationError ( buf::validate::ValidationResult  result,
std::string  message_name 
)

Creates an error of type Type::kRule.

Definition at line 37 of file validate.cpp.

Member Function Documentation

◆ GetDescription()

const std::string & grpc_protovalidate::ValidationError::GetDescription ( ) const

A human-readable description of the error.

Definition at line 51 of file validate.cpp.

◆ GetGrpcStatus()

grpc::Status grpc_protovalidate::ValidationError::GetGrpcStatus ( bool  include_violations = true) const

Constructs a grpc::Status of this error.

Message contains a short human-readable representation of the error. If include_violations is true, details contain the list of violations. Otherwise, details are empty.

Definition at line 61 of file validate.cpp.

◆ GetMessageName()

const std::string & grpc_protovalidate::ValidationError::GetMessageName ( ) const

A fully-qualified name of the message type this error originates from.

Definition at line 49 of file validate.cpp.

◆ GetType()

ValidationError::Type grpc_protovalidate::ValidationError::GetType ( ) const

Get error type.

Definition at line 47 of file validate.cpp.

◆ GetViolations()

const std::vector< buf::validate::RuleViolation > & grpc_protovalidate::ValidationError::GetViolations ( ) const

A list of found contraint violations.

The list is empty if this is a Type::kInternal error.

Definition at line 53 of file validate.cpp.


The documentation for this class was generated from the following files: