blob: f38f2f581f3fca6327ffa56844f4c33b6194482f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
class Email < String
include ActiveModel::Validations
validates :email,
:format => {
:with => /\A([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})\Z/, #checks format, but allows lowercase
:message => "needs to be a valid email address"
}
validates :email,
:format => {
:with => /\A[^A-Z]*\Z/, #forbids uppercase characters
:message => "letters must be lowercase"
}
def to_partial_path
"emails/email"
end
def to_param
to_s
end
def email
self
end
def handle
self.split('@').first
end
end
|