Skip to content
Snippets Groups Projects
Commit 44b00a1e authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Extract CI entry config hash validation to validator

parent 2a87a55f
No related branches found
No related tags found
1 merge request!4560Improve validations and error handling in new CI config entries
Pipeline #
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment