Class: API::Validations::Validators::GitSha

Inherits:
Grape::Validations::Base
  • Object
show all
Defined in:
lib/api/validations/validators/git_sha.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
# File 'lib/api/validations/validators/git_sha.rb', line 7

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

  return if Commit::EXACT_COMMIT_SHA_PATTERN.match?(sha)

  raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)],
                                        message: "should be a valid sha"
end