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
41 42 43 44 45 46 |
# File 'lib/coradoc/validation.rb', line 41 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.
33 34 35 |
# File 'lib/coradoc/validation.rb', line 33 def code @code end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
33 34 35 |
# File 'lib/coradoc/validation.rb', line 33 def element @element end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
33 34 35 |
# File 'lib/coradoc/validation.rb', line 33 def @message end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
33 34 35 |
# File 'lib/coradoc/validation.rb', line 33 def path @path end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash
62 63 64 |
# File 'lib/coradoc/validation.rb', line 62 def to_h { message: , path: path, code: code } end |
#to_s ⇒ String
Format error as string
51 52 53 54 55 56 57 |
# File 'lib/coradoc/validation.rb', line 51 def to_s if path "#{path}: #{}" else end end |