Sha256: 67822a070ad405085819744e6b13509a6eb77838765b015142daf3299b57fdb8

Contents?: true

Size: 414 Bytes

Versions: 7

Compression:

Stored size: 414 Bytes

Contents

require 'uri'

module CLIUtils
  # A Validator to verify whether a Pref answer
  # is a valid URL.
  class UrlValidator < PrefValidator
    # Runs the Validator against the answer.
    # @param [Object] text The "text" to evaluate
    # @return [String]
    def validate(text)
      @is_valid = text.to_s =~ URI::DEFAULT_PARSER.regexp[:ABS_URI]
      @message = "Response is not a URL: #{ 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/url_validator.rb
cliutils-2.2.5 lib/cliutils/prefs/pref_validators/url_validator.rb
cliutils-2.2.4 lib/cliutils/prefs/pref_validators/url_validator.rb
cliutils-2.2.3 lib/cliutils/prefs/pref_validators/url_validator.rb
cliutils-2.2.2 lib/cliutils/prefs/pref_validators/url_validator.rb
cliutils-2.2.1 lib/cliutils/prefs/pref_validators/url_validator.rb
cliutils-2.2.0 lib/cliutils/prefs/pref_validators/url_validator.rb