ash_postgres/lib/verifiers/validate_references.ex
Zach Daniel 37cc01957d
improvement!: 3.0 (#227)
* WIP

* chore: fix mix.lock merge issues

* improvement: upgrade to 3.0

* chore: remove `repo.to_tenant`

* chore: continue removal of unnecessary helper

* chore: use `Ash.ToTenant`
2024-03-27 16:52:28 -04:00

21 lines
648 B
Elixir

defmodule AshPostgres.Verifiers.ValidateReferences do
@moduledoc false
use Spark.Dsl.Verifier
alias Spark.Dsl.Verifier
def verify(dsl) do
dsl
|> AshPostgres.DataLayer.Info.references()
|> Enum.each(fn reference ->
unless Ash.Resource.Info.relationship(dsl, reference.relationship) do
raise Spark.Error.DslError,
path: [:postgres, :references, reference.relationship],
module: Verifier.get_persisted(dsl, :module),
message:
"Found reference configuration for relationship `#{reference.relationship}`, but no such relationship exists"
end
end)
:ok
end
end