Class: AnyVali::ValidationIssue
- Inherits:
-
Object
- Object
- AnyVali::ValidationIssue
- Defined in:
- lib/anyvali/validation_issue.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#received ⇒ Object
readonly
Returns the value of attribute received.
Instance Method Summary collapse
-
#initialize(code:, message: nil, path: [], expected: nil, received: nil, meta: nil) ⇒ ValidationIssue
constructor
A new instance of ValidationIssue.
- #to_h ⇒ Object
Constructor Details
#initialize(code:, message: nil, path: [], expected: nil, received: nil, meta: nil) ⇒ ValidationIssue
Returns a new instance of ValidationIssue.
7 8 9 10 11 12 13 14 15 |
# File 'lib/anyvali/validation_issue.rb', line 7 def initialize(code:, message: nil, path: [], expected: nil, received: nil, meta: nil) @code = code @message = || (code) @path = path.freeze @expected = expected @received = received @meta = freeze end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/anyvali/validation_issue.rb', line 5 def code @code end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
5 6 7 |
# File 'lib/anyvali/validation_issue.rb', line 5 def expected @expected end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/anyvali/validation_issue.rb', line 5 def @message end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
5 6 7 |
# File 'lib/anyvali/validation_issue.rb', line 5 def @meta end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/anyvali/validation_issue.rb', line 5 def path @path end |
#received ⇒ Object (readonly)
Returns the value of attribute received.
5 6 7 |
# File 'lib/anyvali/validation_issue.rb', line 5 def received @received end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/anyvali/validation_issue.rb', line 17 def to_h h = { "code" => @code, "path" => @path.dup } h["expected"] = @expected unless @expected.nil? h["received"] = @received unless @received.nil? h["message"] = @message if @message h["meta"] = @meta if @meta h end |