Class: EmailValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- EmailValidator
- Defined in:
- lib/trogdir/validators/email_validator.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
6 7 8 |
# File 'lib/trogdir/validators/email_validator.rb', line 6 def attribute @attribute end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
6 7 8 |
# File 'lib/trogdir/validators/email_validator.rb', line 6 def email @email end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
6 7 8 |
# File 'lib/trogdir/validators/email_validator.rb', line 6 def record @record end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
6 7 8 |
# File 'lib/trogdir/validators/email_validator.rb', line 6 def tree @tree end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/trogdir/validators/email_validator.rb', line 6 def value @value end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/trogdir/validators/email_validator.rb', line 8 def validate_each(record, attribute, value) @record, @attribute, @value = record, attribute, value @email = Mail::Address.new(value) @tree = email.__send__(:tree) add_error unless valid? rescue Mail::Field::ParseError add_error end |