Sha256: b6e626917cec8dc75b6199a084aa1057cb25be8767c810a95edb44ce3903d0ad

Contents?: true

Size: 750 Bytes

Versions: 11

Compression:

Stored size: 750 Bytes

Contents

module Chef::Validation
  module Formatter
    class << self
      # Formats an error hash returned by `Chef::Validation.run/2` into a human readable
      # string to be output in a Chef run.
      #
      # @param [Hash] errors
      #
      # @return [String]
      def format_errors(errors)
        msg = []
        msg << "Attribute Validation failure report:"
        msg << ""
        errors.each do |cookbook, attrs|
          msg << "  # '#{cookbook}' failed validation for (#{attrs.length}) attribute(s)."
          attrs.each do |name, errs|
            msg << "    * #{name}"
            errs.each do |err|
              msg << "      - #{err}"
            end
          end
        end
        msg.join("\n")
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
chef-validation-0.2.3 lib/chef/validation/formatter.rb
chef-validation-0.2.2 lib/chef/validation/formatter.rb
chef-validation-0.2.1 lib/chef/validation/formatter.rb
chef-validation-0.2.0 lib/chef/validation/formatter.rb
chef-validation-0.1.6 lib/chef/validation/formatter.rb
chef-validation-0.1.5 lib/chef/validation/formatter.rb
chef-validation-0.1.4 lib/chef/validation/formatter.rb
chef-validation-0.1.3 lib/chef/validation/formatter.rb
chef-validation-0.1.2 lib/chef/validation/formatter.rb
chef-validation-0.1.1 lib/chef/validation/formatter.rb
chef-validation-0.1.0 lib/chef/validation/formatter.rb