diff options
author | jubianchi <contact@jubianchi.fr> | 2014-08-17 22:22:01 +0200 |
---|---|---|
committer | jubianchi <contact@jubianchi.fr> | 2014-08-20 12:09:19 +0200 |
commit | 7ad93ab250019d7737186a0bf8884faf2db2b625 (patch) | |
tree | cd75991df1a3fe502549dd4f0a1b1d35ba6ddb58 /lib/api/helpers.rb | |
parent | ed9e922dd0047435b8d349f0c949ba0a2d789247 (diff) | |
download | gitlab-ce-7ad93ab250019d7737186a0bf8884faf2db2b625.tar.gz |
Improve labels validation and expose error messages
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index d36b29a00b1..6af0f6d1b25 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -114,17 +114,21 @@ module API # Helper method for validating all labels against its names def validate_label_params(params) + errors = {} + 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 + errors[label.title] = label.errors end end end - false + + errors end # error helpers |