# frozen_string_literal: true module Diffend # Module for all the components related to setting up the config module Config # Class responsible for validating the config from .diffend.yml module Validator class << self # @param config [OpenStruct] path of the current build def call(config) raise Errors::ProjectIdMissingInConfigurationFile if missing?(config, 'project_id') raise Errors::ShareableIdMissingInConfigurationFile if missing?(config, 'shareable_id') raise Errors::ShareableKeyMissingInConfigurationFile if missing?(config, 'shareable_key') raise Errors::BuildPathMissingInConfigurationFile if missing?(config, 'build_path') end private def missing?(config, key) config.public_send(key).nil? || config.public_send(key).empty? end end end end end