2018-02-28 16:23:50 +01:00
|
|
|
module EmailSanitizableConcern
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def sanitize_email(attribute)
|
|
|
|
value_to_sanitize = self.send(attribute)
|
|
|
|
if value_to_sanitize.present?
|
2023-01-10 17:20:22 +01:00
|
|
|
self[attribute] = EmailSanitizer.sanitize(value_to_sanitize)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class EmailSanitizer
|
|
|
|
def self.sanitize(value)
|
|
|
|
value.gsub(/[[:space:]]/, ' ').strip.downcase
|
2018-02-28 16:23:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|