Skip to content

Business intelligence made simple

Added email validation

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