Class: Longleaf::StoragePathValidator
- Inherits:
-
Object
- Object
- Longleaf::StoragePathValidator
- Defined in:
- lib/longleaf/services/storage_path_validator.rb
Overview
Validator for storage paths
Class Method Summary collapse
-
.validate(path) ⇒ Object
Checks that the given path is a syntactically valid storage path.
Class Method Details
.validate(path) ⇒ Object
Checks that the given path is a syntactically valid storage path
9 10 11 12 13 14 |
# File 'lib/longleaf/services/storage_path_validator.rb', line 9 def self.validate(path) raise InvalidStoragePathError.new("Path must not be empty") if path.to_s.strip.empty? raise InvalidStoragePathError.new("Path must be absolute") unless Pathname.new(path).absolute? raise InvalidStoragePathError.new("Path must not contain any relative modifiers (/..)") \ if path.include?('/..') end |