Class: Owasp::Esapi::Validator::Email

Inherits:
GenericValidator show all
Defined in:
lib/validator/email.rb

Constant Summary collapse

EMAIL_REGEX =
"^(\\w)+[@](\\w)+[.]\\w{3}$"

Instance Attribute Summary collapse

Attributes inherited from GenericValidator

#matcher

Instance Method Summary collapse

Methods inherited from GenericValidator

#valid?

Constructor Details

#initialize(options = nil) ⇒ Email

Returns a new instance of Email.


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/validator/email.rb', line 14

def initialize(options=nil)
  validate_tld = false
  @matcher = EMAIL_REGEX
  super(@matcher)
  
  unless options.nil? 
    if options.has_key? "validate_tld"
      validate_tld = options["validate_tld"]
    end
  end
end

Instance Attribute Details

#validate_tldObject (readonly)

In order to make a strong validation for email addresses, it might be a good idea to make a check for the domain tld. This is a very optional and beta feature, so it is turned off by default.


12
13
14
# File 'lib/validator/email.rb', line 12

def validate_tld
  @validate_tld
end