Class: CLIUtils::AlphabeticValidator

Inherits:
PrefValidator show all
Defined in:
lib/cliutils/prefs/pref_validators/alphabetic_validator.rb

Overview

A Validator to verify whether a Pref answer is alphabetic (made up of letters and spaces).

Instance Attribute Summary

Attributes inherited from PrefValidator

#is_valid, #message

Instance Method Summary collapse

Methods included from Messaging

#messenger

Instance Method Details

#validate(text) ⇒ String

Runs the Validator against the answer.

Parameters:

  • text (Object)

    The “text” to evaluate

Returns:



8
9
10
11
# File 'lib/cliutils/prefs/pref_validators/alphabetic_validator.rb', line 8

def validate(text)
  @is_valid = text.to_s =~ /\A[A-Za-z\s]+\z/
  @message = "Response is not alphabetic: #{ text }"
end