Sha256: 7b1f6f00cd9db45b3dd47b7c0c7ba9e665a283d2f9a39712a3bb4bb01bd1a42c

Contents?: true

Size: 445 Bytes

Versions: 16

Compression:

Stored size: 445 Bytes

Contents

module CLIUtils
  # A Validator to verify whether a Pref answer
  # is alphanumeric (made up of letters, numbers
  # and spaces).
  class AlphanumericValidator < PrefValidator
    # Runs the Validator against the answer.
    # @param [Object] text The "text" to evaluate
    # @return [String]
    def validate(text)
      @is_valid = text.to_s =~ /\A[A-Za-z0-9\s]+\z/
      @message = "Response is not alphanumeric: #{ text }"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cliutils-2.2.6 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.2.5 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.2.4 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.2.3 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.2.2 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.2.1 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.2.0 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.1.4 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.1.3 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.1.2 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.1.1 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.1.0 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.0.3 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.0.2 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.0.1 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
cliutils-2.0.0 lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb