Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sha_validator.rb « validators « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 085fca4d65d81052e6e7608b71e9a831f2124ebe (plain)
1
2
3
4
5
6
7
8
9
# frozen_string_literal: true

class ShaValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    return if value.blank? || value.match(/\A\h{40}\z/)

    record.errors.add(attribute, 'is not a valid SHA')
  end
end