Class: Lutaml::Qea::Validation::ValidationMessage
- Inherits:
-
Object
- Object
- Lutaml::Qea::Validation::ValidationMessage
- Defined in:
- lib/lutaml/qea/validation/validation_message.rb
Overview
Represents a single validation message with severity, category, and context information
Defined Under Namespace
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#entity_id ⇒ Object
readonly
Returns the value of attribute entity_id.
-
#entity_name ⇒ Object
readonly
Returns the value of attribute entity_name.
-
#entity_type ⇒ Object
readonly
Returns the value of attribute entity_type.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
-
#error? ⇒ Boolean
Checks if this is an error message.
-
#info? ⇒ Boolean
Checks if this is an info message.
-
#initialize(severity:, category:, entity_type:, entity_id:, entity_name:, message:, field: nil, reference: nil, location: nil, context: {}) ⇒ ValidationMessage
constructor
Creates a new validation message.
-
#to_h ⇒ Hash
Returns a hash representation of the message.
-
#to_json(*args) ⇒ String
Returns a JSON representation of the message.
-
#to_s ⇒ String
Returns a formatted string representation of the message.
-
#warning? ⇒ Boolean
Checks if this is a warning message.
Constructor Details
#initialize(severity:, category:, entity_type:, entity_id:, entity_name:, message:, field: nil, reference: nil, location: nil, context: {}) ⇒ ValidationMessage
Creates a new validation message
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 57 def initialize( # rubocop:disable Metrics/ParameterLists severity:, category:, entity_type:, entity_id:, entity_name:, message:, field: nil, reference: nil, location: nil, context: {} ) @severity = severity @category = category @entity_type = entity_type @entity_id = entity_id @entity_name = entity_name @field = field @reference = reference @message = @location = location @context = context end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def category @category end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def context @context end |
#entity_id ⇒ Object (readonly)
Returns the value of attribute entity_id.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def entity_id @entity_id end |
#entity_name ⇒ Object (readonly)
Returns the value of attribute entity_name.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def entity_name @entity_name end |
#entity_type ⇒ Object (readonly)
Returns the value of attribute entity_type.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def entity_type @entity_type end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def field @field end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def @message end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def reference @reference end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
40 41 42 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 40 def severity @severity end |
Instance Method Details
#error? ⇒ Boolean
Checks if this is an error message
84 85 86 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 84 def error? severity == Severity::ERROR end |
#info? ⇒ Boolean
Checks if this is an info message
98 99 100 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 98 def info? severity == Severity::INFO end |
#to_h ⇒ Hash
Returns a hash representation of the message
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 119 def to_h # rubocop:disable Metrics/MethodLength { severity: severity, category: category, entity_type: entity_type, entity_id: entity_id, entity_name: entity_name, field: field, reference: reference, message: , location: location, context: context, }.compact end |
#to_json(*args) ⇒ String
Returns a JSON representation of the message
137 138 139 140 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 137 def to_json(*args) require "json" to_h.to_json(*args) end |
#to_s ⇒ String
Returns a formatted string representation of the message
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/lutaml/qea/validation/validation_message.rb', line 105 def to_s # rubocop:disable Metrics/AbcSize parts = [] parts << "#{entity_type.to_s.capitalize} '#{entity_name}'" parts << "{#{entity_id}}" parts << "└─ #{}" parts << "└─ Field: #{field}" if field parts << "└─ Reference: #{reference}" if reference parts << "└─ Location: #{location}" if location parts.join("\n") end |