gitlab-org--gitlab-foss/app/validators/cron_timezone_validator.rb
2018-06-27 09:48:37 -07:00

11 lines
382 B
Ruby

# frozen_string_literal: true
# CronTimezoneValidator
#
# Custom validator for CronTimezone.
class CronTimezoneValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
cron_parser = Gitlab::Ci::CronParser.new(record.cron, record.cron_timezone)
record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_timezone_valid?
end
end