Module: Diffend::Configs::Validator

Defined in:
lib/diffend/configs/validator.rb

Overview

Class responsible for validating the config from .diffend.yml

Constant Summary collapse

KNOWN_KEYS =
{
  project_id: [String],
  shareable_id: [String],
  shareable_key: [String],
  build_path: [String],
  env: [String],
  command: [String],
  ignore_errors?: [TrueClass, FalseClass],
  development?: [TrueClass, FalseClass]
}.freeze

Class Method Summary collapse

Class Method Details

.call(config) ⇒ Object

Parameters:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/diffend/configs/validator.rb', line 21

def call(config)
  KNOWN_KEYS.each_key do |key|
    if missing?(config, key)
      missing_key_message(key)
        .tap(&config.logger.method(:fatal))

      raise Diffend::Errors::HandledException
    end

    if invalid?(config, key)
      invalid_key_message(config, key)
        .tap(&config.logger.method(:fatal))

      raise Diffend::Errors::HandledException
    end
  end
end