Class: API::Validations::Validators::BulkImports::SourceFullPath

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

Instance Method Summary collapse

Instance Method Details

#validate_param!(attr_name, params) ⇒ Object

Raises:

  • (Grape::Exceptions::Validation)


34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/api/validations/validators/bulk_imports.rb', line 34

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

  return if params['source_type'] == 'group_entity' && NamespacePathValidator.valid_path?(full_path)
  return if params['source_type'] == 'project_entity' && ProjectPathValidator.valid_path?(full_path)

  raise Grape::Exceptions::Validation.new(
    params: [@scope.full_name(attr_name)],
    message: "must be a relative path and not include protocol, sub-domain, or domain information. " \
             "For example, 'source/full/path' not 'https://example.com/source/full/path'"
  )
end