Class: Dugway::ContactFormValidator
- Inherits:
-
Object
- Object
- Dugway::ContactFormValidator
- Defined in:
- lib/dugway/contact_form_validator.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(params) ⇒ ContactFormValidator
constructor
A new instance of ContactFormValidator.
Constructor Details
#initialize(params) ⇒ ContactFormValidator
Returns a new instance of ContactFormValidator.
6 7 8 |
# File 'lib/dugway/contact_form_validator.rb', line 6 def initialize(params) @params = params end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/dugway/contact_form_validator.rb', line 4 def params @params end |
Instance Method Details
#error_message ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/dugway/contact_form_validator.rb', line 10 def if required_fields.any? { |f| params[f].blank? } 'All fields are required' elsif param_does_not_match(:email, email_format) 'Invalid email address' end end |