Class: Lutaml::Model::ValidationContext
- Inherits:
-
Object
- Object
- Lutaml::Model::ValidationContext
- Defined in:
- lib/lutaml/model/collection.rb
Overview
Internal context class for validation chaining. Allows validations to communicate state and share results. This is an internal API - its interface may change.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Store metadata that can be accessed by subsequent validations.
-
#[]=(key, value) ⇒ Object
Retrieve metadata stored by previous validations.
-
#add_errors(error_list) ⇒ Object
Record that this context received errors.
-
#failed? ⇒ Boolean
Check if any validation has added errors.
-
#initialize ⇒ ValidationContext
constructor
A new instance of ValidationContext.
-
#stop! ⇒ Object
Stop the validation chain - subsequent validations will not run.
-
#stopped? ⇒ Boolean
Check if the validation chain has been stopped.
Constructor Details
#initialize ⇒ ValidationContext
Returns a new instance of ValidationContext.
9 10 11 12 13 |
# File 'lib/lutaml/model/collection.rb', line 9 def initialize @errors = [] @stopped = false @metadata = {} end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/lutaml/model/collection.rb', line 7 def errors @errors end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/lutaml/model/collection.rb', line 7 def @metadata end |
Instance Method Details
#[](key) ⇒ Object
Store metadata that can be accessed by subsequent validations
28 29 30 |
# File 'lib/lutaml/model/collection.rb', line 28 def [](key) @metadata[key] end |
#[]=(key, value) ⇒ Object
Retrieve metadata stored by previous validations
35 36 37 |
# File 'lib/lutaml/model/collection.rb', line 35 def []=(key, value) @metadata[key] = value end |
#add_errors(error_list) ⇒ Object
Record that this context received errors
46 47 48 |
# File 'lib/lutaml/model/collection.rb', line 46 def add_errors(error_list) @errors.concat(error_list) end |
#failed? ⇒ Boolean
Check if any validation has added errors
40 41 42 |
# File 'lib/lutaml/model/collection.rb', line 40 def failed? @errors.any? end |
#stop! ⇒ Object
Stop the validation chain - subsequent validations will not run
21 22 23 |
# File 'lib/lutaml/model/collection.rb', line 21 def stop! @stopped = true end |
#stopped? ⇒ Boolean
Check if the validation chain has been stopped
16 17 18 |
# File 'lib/lutaml/model/collection.rb', line 16 def stopped? @stopped end |