def validate_references
      # If we've already done the validation, don't do it again
      return if @references_validated
      @references_validated = true

      # Skip out early if no reference validation has been requested.
      unless @options[:validate_references].is_a?(Array) && @options[:validate_references].any?
        return
      end

      # Puppet 5 has reference validation built-in and enabled, so there won't even be a valid catalog if
      # there were invalid references. It's pointless to perform validation of our own.
      return if puppet_version && puppet_version >= '5.0.0'

      # Iterate over all the resources and check each one that has one of the attributes being checked.
      # Keep track of all references that are missing for ultimate inclusion in the error message.
      missing = []
      resources.each do |x|
        @options[:validate_references].each do |r|
          next unless x.key?('parameters')
          next unless x['parameters'].key?(r)
          missing_resources = resources_missing_from_catalog(x['parameters'][r])
          next unless missing_resources.any?
          missing.concat missing_resources.map { |missing_target| { source: x, target_type: r, target_value: missing_target } }
        end
      end
      return if missing.empty?

      # At this point there is at least one broken/missing reference. Format an error message and raise.
      errors = format_missing_references(missing)
      plural = errors =~ /;/ ? 's' : ''
      self.error_message = "Catalog has broken reference#{plural}: #{errors}"
    end
def validate_references
      # If we've already done the validation, don't do it again
      return if @references_validated
      @references_validated = true

      # Skip out early if no reference validation has been requested.
      unless @options[:validate_references].is_a?(Array) && @options[:validate_references].any?
        return
      end

      # Puppet 5 has reference validation built-in and enabled, so there won't even be a valid catalog if
      # there were invalid references. It's pointless to perform validation of our own.
      return if puppet_version && puppet_version >= '5.0.0'

      # Iterate over all the resources and check each one that has one of the attributes being checked.
      # Keep track of all references that are missing for ultimate inclusion in the error message.
      missing = []
      resources.each do |x|
        @options[:validate_references].each do |r|
          next unless x.key?('parameters')
          next unless x['parameters'].key?(r)
          missing_resources = resources_missing_from_catalog(x['parameters'][r])
          next unless missing_resources.any?
          missing.concat missing_resources.map { |missing_target| { source: x, target_type: r, target_value: missing_target } }
        end
      end
      return if missing.empty?

      # At this point there is at least one broken/missing reference. Format an error message and raise.
      errors = format_missing_references(missing)
      plural = errors =~ /;/ ? 's' : ''
      self.error_message = "Catalog has broken reference#{plural}: #{errors}"
    end
Determine if all of the (before, notify, require, subscribe) targets are actually in the catalog.
 Raise a OctocatalogDiff::Errors::ReferenceValidationError for any found to be missing.
 Uses @options[:validate_references] to influence which references are checked.