diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-22 06:09:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-22 06:09:18 +0300 |
commit | 6c84e073765fe285844fd1a91b0e30492ad117e8 (patch) | |
tree | b01740490c2903fded3c437b1a56ecd9b674e2b6 /lib | |
parent | 51d09c5698aed5bbfa66a7773db93b674be63a56 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/invitations.rb | 4 | ||||
-rw-r--r-- | lib/api/validations/validators/email_or_email_list.rb | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/api/invitations.rb b/lib/api/invitations.rb index 6fb3eca0ba8..6dd4d55d38a 100644 --- a/lib/api/invitations.rb +++ b/lib/api/invitations.rb @@ -21,8 +21,8 @@ module API end params do requires :access_level, type: Integer, values: Gitlab::Access.all_values, desc: 'A valid access level (defaults: `30`, developer access level)' - optional :email, types: [String, Array[String]], email_or_email_list: true, desc: 'The email address to invite, or multiple emails separated by comma' - optional :user_id, types: [Integer, String], desc: 'The user ID of the new member or multiple IDs separated by commas.' + optional :email, type: Array[String], email_or_email_list: true, coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The email address to invite, or multiple emails separated by comma' + optional :user_id, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The user ID of the new member or multiple IDs separated by commas.' optional :expires_at, type: DateTime, desc: 'Date string in the format YEAR-MONTH-DAY' optional :invite_source, type: String, desc: 'Source that triggered the member creation process', default: 'invitations-api' optional :tasks_to_be_done, type: Array[String], coerce_with: Validations::Types::CommaSeparatedToArray.coerce, desc: 'Tasks the inviter wants the member to do' diff --git a/lib/api/validations/validators/email_or_email_list.rb b/lib/api/validations/validators/email_or_email_list.rb index da665f39130..715a29c613d 100644 --- a/lib/api/validations/validators/email_or_email_list.rb +++ b/lib/api/validations/validators/email_or_email_list.rb @@ -9,7 +9,12 @@ module API return unless value - return if value.split(',').map { |v| ValidateEmail.valid?(v) }.all? + case value + when String + return if value.split(',').map { |v| ValidateEmail.valid?(v) }.all? + when Array + return if value.map { |v| ValidateEmail.valid?(v) }.all? + end raise Grape::Exceptions::Validation.new( params: [@scope.full_name(attr_name)], |