cron_timezone_validator.rb 382 Bytes
Newer Older
1 2
# frozen_string_literal: true

3
# CronTimezoneValidator
4
#
5 6
# Custom validator for CronTimezone.
class CronTimezoneValidator < ActiveModel::EachValidator
7
  def validate_each(record, attribute, value)
8 9
    cron_parser = Gitlab::Ci::CronParser.new(record.cron, record.cron_timezone)
    record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_timezone_valid?
10 11
  end
end