Class: LineCodeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- LineCodeValidator
- Defined in:
- app/validators/line_code_validator.rb
Overview
LineCodeValidator
Custom validator for GitLab line codes.
Constant Summary collapse
- PATTERN =
/\A[a-z0-9]+_\d+_\d+\z/
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
9 10 11 12 13 |
# File 'app/validators/line_code_validator.rb', line 9 def validate_each(record, attribute, value) unless PATTERN.match?(value) record.errors.add(attribute, "must be a valid line code") end end |