Sha256: 8335a3f7ff19bd84abcc5ac186e77e5e0d97a06460bed8f13b1bfa97b45e70fe

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

require 'command_mapper/types/type'

module CommandMapper
  module Types
    #
    # Represents a path to an existing file or a directory.
    #
    class InputPath < Type

      #
      # Validates whether the path exists or not.
      #
      # @param [Object] value
      #
      # @return [true, (false, String)]
      #
      def validate(value)
        unless value.empty?
          unless File.exists?(value)
            return [false, "path does not exist (#{value.inspect})"]
          end
        end

        return true
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
command_mapper-0.1.0 lib/command_mapper/types/input_path.rb
command_mapper-0.1.0.pre1 lib/command_mapper/types/input_path.rb