Class: Longleaf::FilesystemLocationValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/longleaf/services/filesystem_location_validator.rb

Overview

Validates the configuration of a filesystem based location

Class Method Summary collapse

Class Method Details

.validate(p_validator, name, path_prop, section_name, path) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/longleaf/services/filesystem_location_validator.rb', line 8

def self.validate(p_validator, name, path_prop, section_name, path)
  base_msg = "Storage location '#{name}' specifies invalid #{section_name} '#{path_prop}' property: "
  p_validator.assert(base_msg + 'Path must not be empty', !path.nil? && !path.to_s.strip.empty?)
  p_validator.assert(base_msg + 'Path must not contain any relative modifiers (/..)', !path.include?('/..'))
  p_validator.assert(base_msg + 'Path must be absolute', Pathname.new(path).absolute?)
  p_validator.assert(base_msg + 'Path does not exist', Dir.exist?(path))
end