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

line_code_validator.rb « validators « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ed29e5aeb67f08f3e401db4c0f5f815ecf4766b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# LineCodeValidator
#
# Custom validator for GitLab line codes.
class LineCodeValidator < ActiveModel::EachValidator
  PATTERN = /\A[a-z0-9]+_\d+_\d+\z/.freeze

  def validate_each(record, attribute, value)
    unless value =~ PATTERN
      record.errors.add(attribute, "must be a valid line code")
    end
  end
end