class Formulary::HtmlForm::Fields::EmailInput

Constants

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

Public Class Methods

compatible_type() click to toggle source
# File lib/formulary/html_form/fields/email_input.rb, line 12
def self.compatible_type
  "email"
end

Public Instance Methods

error() click to toggle source
Calls superclass method
# 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?() click to toggle source
Calls superclass method
# File lib/formulary/html_form/fields/email_input.rb, line 16
def valid?
  super && email_correct?
end

Protected Instance Methods

email_correct?() click to toggle source
# File lib/formulary/html_form/fields/email_input.rb, line 27
def email_correct?
  return true if @value.blank?
  return true if @value.match(REGEX)
end