Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_email_participant.rb « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bb03b3d72e62e24b950b6f9fd87e549e1f371268 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class IssueEmailParticipant < ApplicationRecord
  include BulkInsertSafe
  include Presentable
  include CaseSensitivity

  belongs_to :issue

  validates :email, uniqueness: { scope: [:issue_id], case_sensitive: false }
  validates :issue, presence: true
  validate :validate_email_format

  scope :with_emails, ->(emails) { iwhere(email: emails) }

  def validate_email_format
    self.errors.add(:email, I18n.t(:invalid, scope: 'valid_email.validations.email')) unless ValidateEmail.valid?(self.email)
  end
end