2017-04-04 12:54:45 -04:00
|
|
|
# CronTimezoneValidator
|
2017-04-04 06:14:49 -04:00
|
|
|
#
|
2017-04-04 12:54:45 -04:00
|
|
|
# Custom validator for CronTimezone.
|
|
|
|
class CronTimezoneValidator < ActiveModel::EachValidator
|
2017-04-04 06:14:49 -04:00
|
|
|
def validate_each(record, attribute, value)
|
2017-04-04 12:54:45 -04:00
|
|
|
cron_parser = Gitlab::Ci::CronParser.new(record.cron, record.cron_timezone)
|
|
|
|
record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_timezone_valid?
|
2017-04-04 06:14:49 -04:00
|
|
|
end
|
|
|
|
end
|