BigW Consortium Gitlab

cron_validator.rb 318 Bytes
Newer Older
Shinya Maeda committed
1 2 3 4 5
# CronValidator
#
# Custom validator for Cron.
class CronValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
6
    cron_parser = Gitlab::Ci::CronParser.new(record.cron, record.cron_timezone)
7
    record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_valid?
Shinya Maeda committed
8 9
  end
end