Class: Formulary::HtmlForm::Fields::EmailInput

Inherits:
Input
  • Object
show all
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.

stackoverflow.com/questions/4940120/is-there-a-java-implementation-of-the-html5-input-email-validation

/[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_typeObject



12
13
14
# File 'lib/formulary/html_form/fields/email_input.rb', line 12

def self.compatible_type
  "email"
end

Instance Method Details

#errorObject



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

Returns:

  • (Boolean)


16
17
18
# File 'lib/formulary/html_form/fields/email_input.rb', line 16

def valid?
  super && email_correct?
end