|
@@ -4,6 +4,7 @@ module Blazer
|
|
belongs_to :query
|
|
belongs_to :query
|
|
|
|
|
|
validates :query_id, presence: true
|
|
validates :query_id, presence: true
|
|
|
|
+ validate :validate_emails
|
|
|
|
|
|
before_validation :set_state
|
|
before_validation :set_state
|
|
before_validation :fix_emails
|
|
before_validation :fix_emails
|
|
@@ -74,5 +75,11 @@ module Blazer
|
|
# but we know what they mean, so let's fix it
|
|
# but we know what they mean, so let's fix it
|
|
self.emails = emails.gsub(";", ",") if emails.present?
|
|
self.emails = emails.gsub(";", ",") if emails.present?
|
|
end
|
|
end
|
|
|
|
+
|
|
|
|
+ def validate_emails
|
|
|
|
+ unless split_emails.all? { |e| e =~ /\A.+@.+\..+\z/ }
|
|
|
|
+ errors.add(:base, "Invalid emails")
|
|
|
|
+ end
|
|
|
|
+ end
|
|
end
|
|
end
|
|
end
|
|
end
|