mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 20:56:08 +10:00
Extract CI entry config hash validation to validator
This commit is contained in:
@@ -19,13 +19,7 @@ module Gitlab
|
||||
|
||||
included do
|
||||
validations do
|
||||
validate :hash_config_value
|
||||
|
||||
def hash_config_value
|
||||
unless self.config.is_a?(Hash)
|
||||
errors.add(:config, 'should be a configuration entry hash')
|
||||
end
|
||||
end
|
||||
validates :config, hash: true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,6 +12,14 @@ module Gitlab
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user