Class: JSI::Validation::FullResult

Inherits:
Result
  • Object
show all
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

Instance Method Summary collapse

Methods inherited from Result

#builder

Constructor Details

#initializeFullResult

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_issuesObject (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_errorsObject (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

#freezeObject



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_fingerprintObject

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.

see Util::Private::FingerprintHash



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

Returns:

  • (Boolean)


138
139
140
# File 'lib/jsi/validation/result.rb', line 138

def valid?
  validation_errors.empty?
end