diff --git a/lib/oban/plugins/reindexer.ex b/lib/oban/plugins/reindexer.ex index 27a8db46..4f290b53 100644 --- a/lib/oban/plugins/reindexer.ex +++ b/lib/oban/plugins/reindexer.ex @@ -78,7 +78,7 @@ defmodule Oban.Plugins.Reindexer do conf: :ok, name: :ok, indexes: {:list, :string}, - schedule: {:custom, &validate_schedule/1}, + schedule: :schedule, timeout: :timeout, timezone: :timezone ) @@ -127,16 +127,6 @@ defmodule Oban.Plugins.Reindexer do {:noreply, schedule_reindex(state)} end - # Validation - - defp validate_schedule(schedule) do - Expression.parse!(schedule) - - :ok - rescue - error in [ArgumentError] -> {:error, error.message} - end - # Scheduling defp schedule_reindex(state) do diff --git a/lib/oban/validation.ex b/lib/oban/validation.ex index 01e8fea6..02238610 100644 --- a/lib/oban/validation.ex +++ b/lib/oban/validation.ex @@ -110,6 +110,15 @@ defmodule Oban.Validation do {:error, "expected #{inspect(key)} to be between #{min}..#{max}, got: #{inspect(val)}"} end + defp validate_type(:schedule, key, val) do + Oban.Cron.Expression.parse!(val) + + :ok + rescue + error in [ArgumentError] -> + {:error, "expected #{inspect(key)} to be a valid cron schedule, got: #{error.message}"} + end + defp validate_type(:string, key, val) when not is_binary(val) do {:error, "expected #{inspect(key)} to be a string, got: #{inspect(val)}"} end