Sha256: 4f28443a5ac92fb958c3a7d69fa78f65aaf07eceec9ef61bd317dc46e6c03c31

Contents?: true

Size: 740 Bytes

Versions: 3

Compression:

Stored size: 740 Bytes

Contents

require 'pathname'
require 'longleaf/errors'

module Longleaf
  # Validates the configuration of a filesystem based location
  class FilesystemLocationValidator

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
longleaf-1.1.1 lib/longleaf/services/filesystem_location_validator.rb
longleaf-1.1.0 lib/longleaf/services/filesystem_location_validator.rb
longleaf-1.0.0 lib/longleaf/services/filesystem_location_validator.rb