Class: EmailAddressValidation
- Inherits:
-
Validation
show all
- Defined in:
- lib/yodel/models/core/validations/email_address_validation.rb
Instance Attribute Summary
Attributes inherited from Validation
#field, #params
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Validation
#initialize, #to_json
Constructor Details
This class inherits a constructor from Validation
Class Method Details
.validate(params, field, name, value, record, errors) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/yodel/models/core/validations/email_address_validation.rb', line 2
def self.validate(params, field, name, value, record, errors)
begin
address = Mail::Address.new(value)
if address.domain.present? && address.address == value
domain_tree = address.send(:tree).domain
if domain_tree.dot_atom_text.elements.size > 1
return true
end
end
rescue
end
errors[field.name] << new(name)
end
|
Instance Method Details
#describe ⇒ Object
21
22
23
|
# File 'lib/yodel/models/core/validations/email_address_validation.rb', line 21
def describe
"must be a valid email address"
end
|