BigW Consortium Gitlab

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