summaryrefslogtreecommitdiff
path: root/app/models/issue_email_participant.rb
blob: 8eb9b6a815210d72f14e11ac819bbfa5144eb3d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# frozen_string_literal: true

class IssueEmailParticipant < ApplicationRecord
  belongs_to :issue

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

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