summaryrefslogtreecommitdiff
path: root/app/models/broadcast_message.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-19 20:11:01 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-19 20:11:01 +0200
commitd1e8495890ed28d221595e3a60c2df8567b277c1 (patch)
tree8b02d16f64574d70ad04862fd4cc3ea504b64c73 /app/models/broadcast_message.rb
parente78c51f7cf2686e081e7f17f60ef1e9eb4d7bb76 (diff)
downloadgitlab-ce-d1e8495890ed28d221595e3a60c2df8567b277c1.tar.gz
Add validations to BroadcastMessage color and font
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/broadcast_message.rb')
-rw-r--r--app/models/broadcast_message.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb
index 05b4dfc366e..bebe0da9c61 100644
--- a/app/models/broadcast_message.rb
+++ b/app/models/broadcast_message.rb
@@ -20,6 +20,9 @@ class BroadcastMessage < ActiveRecord::Base
validates :starts_at, presence: true
validates :ends_at, presence: true
+ validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
+ validates :font, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true
+
def self.current
where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last
end