Ecto's cast_embed for API schema validation

Hi, I’m trying to use Ecto for validating schema of incoming HTTP requests. I’d like to validate that the clients pass the “children” key in the JSON payload, but it seems that Ecto returns the same changeset regardless of the presence of the key. Looks like I’ll have to reach out to the params passed to the changeset function to validate that condition. Or is there a better way?

iex> Parent.changeset(%{"children" => []}) |> Map.delete(:params) == Parent.changeset(%{}) |> Map.delete(:params)
true
defmodule Parent do
  use Ecto.Schema
  import Ecto.Changeset

  @primary_key false

  embedded_schema do
    embeds_many :children, Child
  end

  def changeset(params) do
    cast(%Parent{}, params, [])
    |> cast_embed(:children)
  end
end

defmodule Child do
  use Ecto.Schema
  import Ecto.Changeset

  @primary_key false

  embedded_schema do
    field :x, :integer
  end

  def changeset(child, params) do
    child
    |> cast(params, [:x])
    |> validate_required([:x])
  end
end

Note that cast_embed(:children, required: true) does not solve my problem, since it invalidates the changeset if the “children” is an empty list which is valid in this particular case.