diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-04-04 19:54:45 +0300 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-04-06 17:46:59 +0300 |
commit | 4688eb47c6fe135fb9baad5a5d56b1dfa685cc7f (patch) | |
tree | 73ed8531a88ff7088ea419aa4518be02cd82f3ae /app/validators/cron_timezone_validator.rb | |
parent | 1dbc888e3306f30ca0882aece86ccd1a817e0ab8 (diff) |
Rename cron_time_zone to cron_timezone. Separate add_concurrent_foreign_key.
Diffstat (limited to 'app/validators/cron_timezone_validator.rb')
-rw-r--r-- | app/validators/cron_timezone_validator.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/validators/cron_timezone_validator.rb b/app/validators/cron_timezone_validator.rb new file mode 100644 index 00000000000..542c7d006ad --- /dev/null +++ b/app/validators/cron_timezone_validator.rb @@ -0,0 +1,9 @@ +# 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 |