gitlab-org--gitlab-foss/app/validators/cron_validator.rb

10 lines
318 B
Ruby
Raw Normal View History

2017-03-31 13:02:26 -04:00
# CronValidator
#
# Custom validator for Cron.
class CronValidator < 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_valid?
2017-03-31 13:02:26 -04:00
end
end