mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 20:35:59 +08:00
12 lines
339 B
Ruby
12 lines
339 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class EmailAddressValidator
|
||
|
def self.valid_value?(email)
|
||
|
email.match? email_regex
|
||
|
end
|
||
|
|
||
|
def self.email_regex
|
||
|
/\A[a-zA-Z0-9!#\$%&'*+\/=?\^_`{|}~\-]+(?:\.[a-zA-Z0-9!#\$%&'\*+\/=?\^_`{|}~\-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?$\z/
|
||
|
end
|
||
|
end
|