Validating a parent/child schema "aggregate"

I couldn’t think of a good name for this topic, so I’ll try to give an example of what I am trying to achieve.

Lets assume I am trying to capture someone’s address history. I have an “AddressHistory” schema, which defines the period of time I wish to capture dates for. There is an “Address” struct which belongs to the “AddressHistory”

I would like to prevent users adding Addresses with a move in date after the end of the period of time defined in the “AddressHistory”

So basically the parent “AddressHistory” constrains the valid data for it’s components (Addresses)

Should I be passing an Address changeset to an AddressHistory.cast_address() fn?
Is there a best practice for something like this?

I’d put that validation in the context function. Something like this:

defmodule MyApp.Addresses do
  def add_address(%User{} = user, params) do
    MyApp.Repo.transaction(fn ->
      with existing <- list_addresses(user),
           {:ok, address} <- insert_address(user, params) do
           :ok <- validate_new_address(user, existing, address),
           {:ok, _history} <- insert_address_history(address) do
        {:ok, address}
      else
        {:error, reason} -> MyApp.Repo.rollback(reason)
    end)
  end
end