diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2014-08-14 10:17:52 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2014-08-14 10:17:52 +0200 |
commit | cbc90565b55d89704d64bc48db323b82b739a873 (patch) | |
tree | f6bb4220068bafab7a1b1a57d2b13631a553c4a2 /lib/api/helpers.rb | |
parent | 04ad197bcc41a26da2c2a80c5b4ffbfad2c296ee (diff) | |
download | gitlab-ce-cbc90565b55d89704d64bc48db323b82b739a873.tar.gz |
Do label validation for issues/merge requests API
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! |