Is it possible to use embed schema with a map?

With @spec you can define the the values of a map to be a certain type.

Is it possible to embed Ecto schema that describe a value inside a map? Or even deeper relationships?
For example, I want to store data that looks something like this:

   countries: [
      %{code: "ab"},
      %{code: "cd"},
      # ...

where the members of the array can be described by an embedded schema? This looks maybe crazy, but it is not for relational database, so the nesting is more deep.

You can use struct but if you want to validate the fields, embedded_schema may suit your need

embedded_schema/1 is used for defining schemas that are embedded in other schemas or only exist in-memory. For example, you can use such schemas to receive data from a command line interface and validate it, without ever persisting it elsewhere.

defmodule Country do
  use Ecto.Schema

  embedded_schema do
    field :code, :string

yes, but I cannot find the syntax for doing this when it is the value of a map (the keys are arbitrary strings). Sorry I am probably explaining this bad

Perhaps this could help: Ecto.Schema — Ecto v3.5.6.