Class: Formulary::HtmlForm::Fields::EmailInput
- Defined in:
- lib/formulary/html_form/fields/email_input.rb
Constant Summary collapse
- REGEX =
The acceptable email pattern in the standard is defined in a language that might not be possible to use in Ruby. Or if it is, we haven’t spent the time to find out or not. We did find this supposedly compatible regex on StackOverflow and it passes our tests so we’re rolling with that for now.
/[A-Za-z0-9!#$%&'*+-\/=?^_`{|}~]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+/
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Input
compatible_with?, supports_required?
Methods inherited from Field
#get_value_from_data_field, #initialize, #is_hidden?, #label, #name, #set_value, supports_required?
Constructor Details
This class inherits a constructor from Formulary::HtmlForm::Fields::Field
Class Method Details
.compatible_type ⇒ Object
12 13 14 |
# File 'lib/formulary/html_form/fields/email_input.rb', line 12 def self.compatible_type "email" end |
Instance Method Details
#error ⇒ Object
20 21 22 23 |
# File 'lib/formulary/html_form/fields/email_input.rb', line 20 def error return super if super.present? return "'#{label}' is not a valid email address" unless email_correct? end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/formulary/html_form/fields/email_input.rb', line 16 def valid? super && email_correct? end |