Fix pipeline validation not working
This commit is contained in:
parent
09d2e4ae72
commit
c37bed932f
|
@ -18,11 +18,10 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
|||
|
||||
@impl Stage
|
||||
def validate_opts(opts) when is_map(opts) do
|
||||
# todo: figure out why this errors when an empty map is provided
|
||||
opts =
|
||||
case opts["extractor"] do
|
||||
nil ->
|
||||
{:ok, %{opts | extractor: "builtin"}}
|
||||
{:ok, Map.put(opts, "extractor", "builtin")}
|
||||
|
||||
extractor when not is_binary(extractor) ->
|
||||
{:error, "extractor must be a string"}
|
||||
|
@ -44,7 +43,7 @@ defmodule Frenzy.Pipeline.ScrapeStage do
|
|||
{:ok, opts} ->
|
||||
case opts["convert_to_data_uris"] do
|
||||
nil ->
|
||||
{:ok, %{opts | convert_to_data_uris: true}}
|
||||
{:ok, Map.put(opts, "convert_to_data_uris", true)}
|
||||
|
||||
value when is_boolean(value) ->
|
||||
{:ok, opts}
|
||||
|
|
|
@ -105,7 +105,7 @@ defmodule FrenzyWeb.PipelineController do
|
|||
else
|
||||
{:error, reason} ->
|
||||
conn
|
||||
|> put_flash(:error, "Unable to edit pipeline: #{inspect(reason)}")
|
||||
|> put_flash(:error, "Unable to edit pipeline: #{reason}")
|
||||
|> render("edit.html", %{
|
||||
pipeline: pipeline,
|
||||
name: name,
|
||||
|
@ -123,7 +123,7 @@ defmodule FrenzyWeb.PipelineController do
|
|||
{:cont, {:ok, new_stages ++ [stage]}}
|
||||
|
||||
{:error, reason} ->
|
||||
{:error, "invalid stage at #{index}: #{reason}"}
|
||||
{:halt, {:error, "invalid stage at index #{index}: #{reason}"}}
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue