Class: JsonStructure::ValidationError
- Inherits:
-
Object
- Object
- JsonStructure::ValidationError
- Defined in:
- lib/jsonstructure/validation_result.rb
Overview
Represents a validation error
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #info? ⇒ Boolean
-
#initialize(code:, severity:, path:, message:, location:) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #warning? ⇒ Boolean
Constructor Details
#initialize(code:, severity:, path:, message:, location:) ⇒ ValidationError
Returns a new instance of ValidationError.
8 9 10 11 12 13 14 |
# File 'lib/jsonstructure/validation_result.rb', line 8 def initialize(code:, severity:, path:, message:, location:) @code = code @severity = severity @path = path @message = @location = location end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/jsonstructure/validation_result.rb', line 6 def code @code end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/jsonstructure/validation_result.rb', line 6 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/jsonstructure/validation_result.rb', line 6 def @message end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/jsonstructure/validation_result.rb', line 6 def path @path end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
6 7 8 |
# File 'lib/jsonstructure/validation_result.rb', line 6 def severity @severity end |
Instance Method Details
#error? ⇒ Boolean
16 17 18 |
# File 'lib/jsonstructure/validation_result.rb', line 16 def error? @severity == FFI::JS_SEVERITY_ERROR end |
#info? ⇒ Boolean
24 25 26 |
# File 'lib/jsonstructure/validation_result.rb', line 24 def info? @severity == FFI::JS_SEVERITY_INFO end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/jsonstructure/validation_result.rb', line 36 def inspect "#<#{self.class.name} @severity=#{@severity} @code=#{@code} @message=#{@message.inspect} @path=#{@path.inspect}>" end |
#to_s ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/jsonstructure/validation_result.rb', line 28 def to_s if @path && !@path.empty? "#{@message} (at #{@path})" else @message end end |
#warning? ⇒ Boolean
20 21 22 |
# File 'lib/jsonstructure/validation_result.rb', line 20 def warning? @severity == FFI::JS_SEVERITY_WARNING end |