diff options
| author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-24 08:58:09 +0200 |
|---|---|---|
| committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-24 08:58:09 +0200 |
| commit | 04ece6664a04e7c352582100bdd6e8d78c3ea7cc (patch) | |
| tree | 5ec3a83d0ae86c7162f569561c28f72c48caa7fe /lib | |
| parent | 823970b570463bb011fbdc1117a1450310763da0 (diff) | |
| download | gitlab-ce-04ece6664a04e7c352582100bdd6e8d78c3ea7cc.tar.gz | |
Add ci config class that represents a key value
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/ci/config/node/key.rb | 18 | ||||
| -rw-r--r-- | lib/gitlab/ci/config/node/validators.rb | 10 |
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/gitlab/ci/config/node/key.rb b/lib/gitlab/ci/config/node/key.rb new file mode 100644 index 00000000000..f8b461ca098 --- /dev/null +++ b/lib/gitlab/ci/config/node/key.rb @@ -0,0 +1,18 @@ +module Gitlab + module Ci + class Config + module Node + ## + # Entry that represents a key. + # + class Key < Entry + include Validatable + + validations do + validates :config, key: true + end + end + end + end + end +end diff --git a/lib/gitlab/ci/config/node/validators.rb b/lib/gitlab/ci/config/node/validators.rb index 56f7661daf0..f2b3a8a3f81 100644 --- a/lib/gitlab/ci/config/node/validators.rb +++ b/lib/gitlab/ci/config/node/validators.rb @@ -13,6 +13,16 @@ module Gitlab end end + class KeyValidator < ActiveModel::EachValidator + include LegacyValidationHelpers + + def validate_each(record, attribute, value) + unless validate_string(value) + record.errors.add(attribute, 'should be a string or symbol') + end + end + end + class TypeValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) type = options[:with] |
