Extract CI entry config hash validation to validator
This commit is contained in:
parent
2a87a55f87
commit
44b00a1ebb
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue