Sha256: c07c0ef7fe274ba1c2cbaa547de1dc7d5f6a3fa450be3477ea32a59a73e3d452
Contents?: true
Size: 490 Bytes
Versions: 2
Compression:
Stored size: 490 Bytes
Contents
# frozen_string_literal: true require 'parse-cron' module TasksScheduler class CronSchedulingValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if value_valid?(value) record.errors.add(attribute, (options[:message] || I18n.t(:cron_scheduling_validator_error_message))) end private def value_valid?(value) ::CronParser.new(value).next true rescue ArgumentError false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tasks_scheduler-0.9.4 | lib/tasks_scheduler/cron_scheduling_validator.rb |
tasks_scheduler-0.9.3 | lib/tasks_scheduler/cron_scheduling_validator.rb |