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 =

List of known config 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:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/diffend/configs/validator.rb', line 30

def call(config)
  KNOWN_KEYS.each_key do |key|
    if missing?(config, key)
      config.errors << ErrorMessages.missing_key(key)
      next
    end

    config.errors << ErrorMessages.invalid_key(config, key) if invalid?(config, key)
  end

  UUID_KEYS.each do |key|
    next if valid_uuid?(config, key)

    config.errors << ErrorMessages.invalid_uuid(key)
  end
end