Class: CronFreezePeriodTimezoneValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/cron_freeze_period_timezone_validator.rb

Overview

CronTimezoneValidator

Custom validator for CronTimezone.

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object


7
8
9
10
11
12
# File 'app/validators/cron_freeze_period_timezone_validator.rb', line 7

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