defmodule M1 do
defstruct [:a, :b, :c, :d]
# other stuff
end
# ...............
schema "my_model" do
# .................
field :my_field, M1, virtual: true
Error
** (ArgumentError) invalid or unknown type MyApp.M1 for field :my_field
The module M1 is resolved but why is it disallowed to use it?
You can optionally not type check virtual fields by declaring as type :any
Does that help?
[Edit] You could also define and use a custom Ecto.Type per my previous link, but I don’t see what the benefit would be. Of course, if it were not a virtual field, you would have to define a custom Ecto.Type.