Sha256: 7e070070488cf9bb78783ce18603cc625cae2c17b6b0f7636c060596489bb61c

Contents?: true

Size: 434 Bytes

Versions: 7

Compression:

Stored size: 434 Bytes

Contents

require 'pathname'

module CLIUtils
  # A Validator to verify whether a Pref answer
  # is a local filepath that exists.
  class FilepathExistsValidator < PrefValidator
    # Runs the Validator against the answer.
    # @param [Object] text The "text" to evaluate
    # @return [String]
    def validate(text)
      @is_valid = Pathname.new(text.to_s).exist?
      @message = "Path does not exist locally: #{ text }"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cliutils-2.2.6 lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb
cliutils-2.2.5 lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb
cliutils-2.2.4 lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb
cliutils-2.2.3 lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb
cliutils-2.2.2 lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb
cliutils-2.2.1 lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb
cliutils-2.2.0 lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb