Module: Avromatic::Patches::SchemaValidatorPatchV040

Defined in:
lib/avromatic/patches/schema_validator_patch.rb

Instance Method Summary collapse

Instance Method Details

#validate_recursive(expected_schema, logical_datum, path, result, options = {}) ⇒ Object

This method replaces validate_recursive in AvroPatches::LogicalTypes::SchemaValidatorPatch to enable validating datums that contain an encoding provider.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/avromatic/patches/schema_validator_patch.rb', line 25

def validate_recursive(expected_schema, logical_datum, path, result, options = {})
  datum = resolve_datum(expected_schema, logical_datum, options[:encoded])
  case expected_schema.type_sym
  when :record, :error, :request
    if datum.is_a?(Hash) && datum.key?(Avromatic::IO::ENCODING_PROVIDER)
      return if expected_schema.sha256_resolution_fingerprint ==
        datum[Avromatic::IO::ENCODING_PROVIDER].value_avro_schema.sha256_resolution_fingerprint
      raise Avro::SchemaValidator::ValidationError
    end
  end
  super(expected_schema, logical_datum, path, result, options)
end