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

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

class CertificateFingerprintValidator < ActiveModel::EachValidator
  FINGERPRINT_PATTERN = /\A([a-zA-Z0-9]{2}[\s\-:]?){16,}\z/.freeze

  def validate_each(record, attribute, value)
    unless value.try(:match, FINGERPRINT_PATTERN)
      record.errors.add(attribute, "must be a hash containing only letters, numbers, spaces, : and -")
    end
  end
end