Class: Overcommit::ConfigurationValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/overcommit/configuration_validator.rb

Overview

Validates and normalizes a configuration.

Instance Method Summary collapse

Instance Method Details

#validate(hash, options) ⇒ Hash

Validates hash for any invalid options, normalizing where possible.

Parameters:

  • hash (Hash)

    hash representation of YAML config

  • options (Hash)
  • default (Hash)

    a customizable set of options

  • logger (Hash)

    a customizable set of options

Returns:

  • (Hash)

    validated hash (potentially modified)



11
12
13
14
15
16
17
18
19
20
# File 'lib/overcommit/configuration_validator.rb', line 11

def validate(hash, options)
  @options = options.dup
  @log = options[:logger]

  hash = convert_nils_to_empty_hashes(hash)
  ensure_hook_type_sections_exist(hash)
  check_for_missing_enabled_option(hash) unless @options[:default]

  hash
end