Class: CLIUtils::AlphanumericValidator
- Inherits:
-
PrefValidator
- Object
- PrefValidator
- CLIUtils::AlphanumericValidator
- Defined in:
- lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb
Overview
A Validator to verify whether a Pref answer is alphanumeric (made up of letters, numbers and spaces).
Instance Attribute Summary
Attributes inherited from PrefValidator
Instance Method Summary collapse
-
#validate(text) ⇒ String
Runs the Validator against the answer.
Methods included from Messaging
Instance Method Details
#validate(text) ⇒ String
Runs the Validator against the answer.
9 10 11 12 |
# File 'lib/cliutils/prefs/pref_validators/alphanumeric_validator.rb', line 9 def validate(text) @is_valid = text.to_s =~ /\A[A-Za-z0-9\s]+\z/ @message = "Response is not alphanumeric: #{ text }" end |