Class: Cerbos::Output::ValidationError
- Inherits:
-
Object
- Object
- Cerbos::Output::ValidationError
- Defined in:
- lib/cerbos/output/validation_error.rb
Overview
An error that occurred while validating the principal or resource attributes against a schema.
Instance Attribute Summary collapse
-
#message ⇒ String
readonly
The error message.
-
#path ⇒ String
readonly
The path to the attribute that failed validation.
-
#source ⇒ :SOURCE_PRINCIPAL, :SOURCE_RESOURCE
readonly
The source of the invalid attributes.
Instance Method Summary collapse
-
#from_principal? ⇒ Boolean
Check if the principal's attributes failed schema validation.
-
#from_resource? ⇒ Boolean
Check if the resource's attributes failed schema validation.
Instance Attribute Details
#message ⇒ String (readonly)
The error message.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cerbos/output/validation_error.rb', line 6 ValidationError = Output.new_class(:path, :message, :source) do # @!attribute [r] path # The path to the attribute that failed validation. # # @return [String] # @!attribute [r] message # The error message. # # @return [String] # @!attribute [r] source # The source of the invalid attributes. # # @return [:SOURCE_PRINCIPAL, :SOURCE_RESOURCE] def self.from_protobuf(validation_error) new( path: validation_error.path, message: validation_error., source: validation_error.source ) end # Check if the principal's attributes failed schema validation. # # @return [Boolean] def from_principal? source == :SOURCE_PRINCIPAL end # Check if the resource's attributes failed schema validation. # # @return [Boolean] def from_resource? source == :SOURCE_RESOURCE end end |
#path ⇒ String (readonly)
The path to the attribute that failed validation.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cerbos/output/validation_error.rb', line 6 ValidationError = Output.new_class(:path, :message, :source) do # @!attribute [r] path # The path to the attribute that failed validation. # # @return [String] # @!attribute [r] message # The error message. # # @return [String] # @!attribute [r] source # The source of the invalid attributes. # # @return [:SOURCE_PRINCIPAL, :SOURCE_RESOURCE] def self.from_protobuf(validation_error) new( path: validation_error.path, message: validation_error., source: validation_error.source ) end # Check if the principal's attributes failed schema validation. # # @return [Boolean] def from_principal? source == :SOURCE_PRINCIPAL end # Check if the resource's attributes failed schema validation. # # @return [Boolean] def from_resource? source == :SOURCE_RESOURCE end end |
#source ⇒ :SOURCE_PRINCIPAL, :SOURCE_RESOURCE (readonly)
The source of the invalid attributes.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cerbos/output/validation_error.rb', line 6 ValidationError = Output.new_class(:path, :message, :source) do # @!attribute [r] path # The path to the attribute that failed validation. # # @return [String] # @!attribute [r] message # The error message. # # @return [String] # @!attribute [r] source # The source of the invalid attributes. # # @return [:SOURCE_PRINCIPAL, :SOURCE_RESOURCE] def self.from_protobuf(validation_error) new( path: validation_error.path, message: validation_error., source: validation_error.source ) end # Check if the principal's attributes failed schema validation. # # @return [Boolean] def from_principal? source == :SOURCE_PRINCIPAL end # Check if the resource's attributes failed schema validation. # # @return [Boolean] def from_resource? source == :SOURCE_RESOURCE end end |
Instance Method Details
#from_principal? ⇒ Boolean
Check if the principal's attributes failed schema validation.
33 34 35 |
# File 'lib/cerbos/output/validation_error.rb', line 33 def from_principal? source == :SOURCE_PRINCIPAL end |
#from_resource? ⇒ Boolean
Check if the resource's attributes failed schema validation.
40 41 42 |
# File 'lib/cerbos/output/validation_error.rb', line 40 def from_resource? source == :SOURCE_RESOURCE end |