Class: RegexForms::ValidateEmail
- Inherits:
-
Object
- Object
- RegexForms::ValidateEmail
- Defined in:
- lib/regex_forms.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
Instance Method Summary collapse
-
#initialize(email) ⇒ ValidateEmail
constructor
A new instance of ValidateEmail.
- #validateEmail ⇒ Object
Constructor Details
#initialize(email) ⇒ ValidateEmail
Returns a new instance of ValidateEmail.
109 110 111 |
# File 'lib/regex_forms.rb', line 109 def initialize(email) @email = email end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
107 108 109 |
# File 'lib/regex_forms.rb', line 107 def email @email end |
Instance Method Details
#validateEmail ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/regex_forms.rb', line 114 def validateEmail return invalid_response("Email is nil, empty") if invalid_email regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i if regex.match(email) valid_response("Validated Email") else invalid_response("Must be a valid email address: #{email}") end end |