blob: 143a02621363f3c580964b179dc7056c49f2c0ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# frozen_string_literal: true
# CronTimezoneValidator
#
# Custom validator for CronTimezone.
class CronFreezePeriodTimezoneValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
freeze_start_parser = Gitlab::Ci::CronParser.new(record.freeze_start, record.cron_timezone)
freeze_end_parser = Gitlab::Ci::CronParser.new(record.freeze_end, record.cron_timezone)
record.errors.add(attribute, " is invalid syntax") unless freeze_start_parser.cron_timezone_valid? && freeze_end_parser.cron_timezone_valid?
end
end
|