Class: JSI::Validation::FullResult
- Defined in:
- lib/jsi/validation/result.rb
Overview
a full result of validating an instance against its schemas, with each validation error
Instance Attribute Summary collapse
-
#schema_issues ⇒ Object
readonly
Returns the value of attribute schema_issues.
-
#validation_errors ⇒ Object
readonly
Returns the value of attribute validation_errors.
Instance Method Summary collapse
- #+(result) ⇒ Object
- #freeze ⇒ Object
-
#initialize ⇒ FullResult
constructor
A new instance of FullResult.
- #jsi_fingerprint ⇒ Object private
- #merge(result) ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Result
Constructor Details
#initialize ⇒ FullResult
Returns a new instance of FullResult.
130 131 132 133 |
# File 'lib/jsi/validation/result.rb', line 130 def initialize @validation_errors = Set.new @schema_issues = Set.new end |
Instance Attribute Details
#schema_issues ⇒ Object (readonly)
Returns the value of attribute schema_issues.
136 137 138 |
# File 'lib/jsi/validation/result.rb', line 136 def schema_issues @schema_issues end |
#validation_errors ⇒ Object (readonly)
Returns the value of attribute validation_errors.
135 136 137 |
# File 'lib/jsi/validation/result.rb', line 135 def validation_errors @validation_errors end |
Instance Method Details
#+(result) ⇒ Object
159 160 161 |
# File 'lib/jsi/validation/result.rb', line 159 def +(result) FullResult.new.merge(self).merge(result) end |
#freeze ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/jsi/validation/result.rb', line 142 def freeze @validation_errors.each(&:freeze) @schema_issues.each(&:freeze) @validation_errors.freeze @schema_issues.freeze super end |
#jsi_fingerprint ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
165 166 167 168 169 170 171 |
# File 'lib/jsi/validation/result.rb', line 165 def jsi_fingerprint { class: self.class, validation_errors: validation_errors, schema_issues: schema_issues, } end |
#merge(result) ⇒ Object
150 151 152 153 154 155 156 157 |
# File 'lib/jsi/validation/result.rb', line 150 def merge(result) unless result.is_a?(FullResult) raise(TypeError, "not a #{FullResult.name}: #{result.pretty_inspect.chomp}") end validation_errors.merge(result.validation_errors) schema_issues.merge(result.schema_issues) self end |
#valid? ⇒ Boolean
138 139 140 |
# File 'lib/jsi/validation/result.rb', line 138 def valid? validation_errors.empty? end |