diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-03-01 16:37:22 +0200 |
---|---|---|
committer | Alexandru Croitor <acroitor@gitlab.com> | 2019-03-06 13:28:42 +0200 |
commit | be3578d24585c7f330103cc546eb50416cd951d3 (patch) | |
tree | e423c5fac61e5f25e05c5cfc5f2853623f7deaa2 /lib/api/validations | |
parent | ee8cb2d1b37c5c0d990a35af29be2877092eef29 (diff) | |
download | gitlab-ce-be3578d24585c7f330103cc546eb50416cd951d3.tar.gz |
Add array support for labels
* Support label parameter as comma separated and array of strings
for merge requests and issues api endpoints
Diffstat (limited to 'lib/api/validations')
-rw-r--r-- | lib/api/validations/types/labels_list.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/api/validations/types/labels_list.rb b/lib/api/validations/types/labels_list.rb new file mode 100644 index 00000000000..47cd83c29cf --- /dev/null +++ b/lib/api/validations/types/labels_list.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module API + module Validations + module Types + class LabelsList + def self.coerce + lambda do |value| + case value + when String + value.split(',').map(&:strip) + when Array + value.map { |v| v.to_s.split(',').map(&:strip) }.flatten + when LabelsList + value + else + [] + end + end + end + end + end + end +end |