anyone-oslo/pages

View on GitHub
app/models/concerns/pages_core/emailable.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module PagesCore
  module Emailable
    extend ActiveSupport::Concern

    included do
      validates :email,
                presence: true,
                format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i },
                uniqueness: { case_sensitive: false }

      normalizes :email, with: ->(email) { email.strip }
    end
  end
end