debian-mirror-gitlab/lib/api/validations/validators/git_sha.rb

21 lines
478 B
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
module API
module Validations
module Validators
class GitSha < Grape::Validations::Base
def validate_param!(attr_name, params)
sha = params[attr_name]
return if Commit::EXACT_COMMIT_SHA_PATTERN.match?(sha)
2021-02-22 17:27:13 +05:30
raise Grape::Exceptions::Validation.new(
params: [@scope.full_name(attr_name)],
message: "should be a valid sha"
)
2020-04-22 19:07:51 +05:30
end
end
end
end
end