debian-mirror-gitlab/app/validators/sha_validator.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

10 lines
247 B
Ruby
Raw Normal View History

2019-03-13 22:55:13 +05:30
# frozen_string_literal: true
class ShaValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
2019-05-03 19:53:19 +05:30
return if value.blank? || Commit.valid_hash?(value)
2019-03-13 22:55:13 +05:30
record.errors.add(attribute, 'is not a valid SHA')
end
end