Class: API::Validations::Validators::ProjectPortable

Inherits:
Grape::Validations::Validators::Base
  • Object
show all
Defined in:
lib/api/validations/validators/project_portable.rb

Instance Method Summary collapse

Instance Method Details

#validate_param!(attr_name, params) ⇒ Object

Raises:

  • (Grape::Exceptions::Validation)


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/api/validations/validators/project_portable.rb', line 7

def validate_param!(attr_name, params)
  portable = params[attr_name]

  portable_relations = ::BulkImports::FileTransfer.config_for(::Project.new).portable_relations
  return if portable_relations.include?(portable)

  raise Grape::Exceptions::Validation.new(
    params: [@scope.full_name(attr_name)],
    message: "is not portable"
  )
end