Class: Coradoc::Validation::Error
- Inherits:
-
Object
- Object
- Coradoc::Validation::Error
- Defined in:
- lib/coradoc/validation.rb
Overview
A single validation error
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(message, path: nil, code: nil, element: nil) ⇒ Error
constructor
Create a validation error.
-
#to_h ⇒ Hash
Convert to hash.
-
#to_s ⇒ String
Format error as string.
Constructor Details
#initialize(message, path: nil, code: nil, element: nil) ⇒ Error
Create a validation error
81 82 83 84 85 86 |
# File 'lib/coradoc/validation.rb', line 81 def initialize(, path: nil, code: nil, element: nil) @message = @path = path @code = code @element = element end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
73 74 75 |
# File 'lib/coradoc/validation.rb', line 73 def code @code end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
73 74 75 |
# File 'lib/coradoc/validation.rb', line 73 def element @element end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
73 74 75 |
# File 'lib/coradoc/validation.rb', line 73 def @message end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
73 74 75 |
# File 'lib/coradoc/validation.rb', line 73 def path @path end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash
102 103 104 |
# File 'lib/coradoc/validation.rb', line 102 def to_h { message: , path: path, code: code } end |
#to_s ⇒ String
Format error as string
91 92 93 94 95 96 97 |
# File 'lib/coradoc/validation.rb', line 91 def to_s if path "#{path}: #{}" else end end |