1 defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID do
6 def cast(object) when is_binary(object) do
7 # Host has to be present and scheme has to be an http scheme (for now)
8 case URI.parse(object) do
9 %URI{host: nil} -> :error
10 %URI{host: ""} -> :error
11 %URI{scheme: scheme} when scheme in ["https", "http"] -> {:ok, object}
16 def cast(%{"id" => object}), do: cast(object)
18 def cast(_), do: :error
20 def dump(data), do: {:ok, data}
22 def load(data), do: {:ok, data}