diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-15 10:17:16 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-08-15 10:17:16 +0300 |
commit | 433dac7799a1a5fd4a0dfeaa0157148eb9058202 (patch) | |
tree | 363bd1609d2bef7fb502971bc7bb8d51209e5343 /lib/api/helpers.rb | |
parent | 7120af725148aae5092c0870c1da34ca5652f60d (diff) | |
parent | cbc90565b55d89704d64bc48db323b82b739a873 (diff) | |
download | gitlab-ce-433dac7799a1a5fd4a0dfeaa0157148eb9058202.tar.gz |
Merge pull request #7465 from Razer6/better_label_color_validation
Better label color validation, fixes #7454
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 8189e433789..d36b29a00b1 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -112,6 +112,21 @@ module API ActionController::Parameters.new(attrs).permit! end + # Helper method for validating all labels against its names + def validate_label_params(params) + if params[:labels].present? + params[:labels].split(',').each do |label_name| + label = user_project.labels.create_with( + color: Label::DEFAULT_COLOR).find_or_initialize_by( + title: label_name.strip) + if label.invalid? + return true + end + end + end + false + end + # error helpers def forbidden! |