def validate_processor_result!(result)
      if !result.instance_of?(Hash)
        raise TypeError, "processor metadata result was expected to be a Hash, but was #{result.class}"
      end

      if !result[:data].instance_of?(String)
        raise TypeError, "processor :data was expected to be a String, but as #{result[:data].class}"
      end

      result.each do |key, value|
        if !key.instance_of?(Symbol)
          raise TypeError, "processor metadata[#{key.inspect}] expected to be a Symbol"
        end

        if !valid_processor_metadata_value?(value)
          raise TypeError, "processor metadata[:#{key}] returned a complex type: #{value.inspect}\n" +
            "Only #{VALID_METADATA_TYPES.to_a.join(", ")} maybe used."
        end
      end

      result
    end
def validate_processor_result!(result)
      if !result.instance_of?(Hash)
        raise TypeError, "processor metadata result was expected to be a Hash, but was #{result.class}"
      end

      if !result[:data].instance_of?(String)
        raise TypeError, "processor :data was expected to be a String, but as #{result[:data].class}"
      end

      result.each do |key, value|
        if !key.instance_of?(Symbol)
          raise TypeError, "processor metadata[#{key.inspect}] expected to be a Symbol"
        end

        if !valid_processor_metadata_value?(value)
          raise TypeError, "processor metadata[:#{key}] returned a complex type: #{value.inspect}\n" +
            "Only #{VALID_METADATA_TYPES.to_a.join(", ")} maybe used."
        end
      end

      result
    end
Internal: Validate returned result of calling a processor pipeline and
 raise a friendly user error message.

 result - Metadata Hash returned from call_processors

 Returns result or raises a TypeError.