Commit 44b00a1e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extract CI entry config hash validation to validator

parent 2a87a55f
...@@ -19,13 +19,7 @@ module Gitlab ...@@ -19,13 +19,7 @@ module Gitlab
included do included do
validations do validations do
validate :hash_config_value validates :config, hash: true
def hash_config_value
unless self.config.is_a?(Hash)
errors.add(:config, 'should be a configuration entry hash')
end
end
end end
end end
......
...@@ -12,6 +12,14 @@ module Gitlab ...@@ -12,6 +12,14 @@ module Gitlab
end end
end end
end end
class HashValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value.is_a?(Hash)
record.errors.add(attribute, 'should be a configuration entry hash')
end
end
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment