Validating a has_many assoc changeset on update

I have a schema with a :has_many resource that I cast_assoc in the changeset function. On updates, I need to check the :insert_at timestamp of any associated :has_many resource that is being updated.

Where and what is the correct place to implement this check?

Scenario: imagine you have a Character schema that :has_many attributes. Attributes can be added (associated) to a Character without restriction, but existing attributes associated to a Character can only be updated before 5 minutes.

I would suggest you just use a Map (jsonb in PostgreSQL) field of your characters table and then use Ecto’s embeds_many facility, where the embedded struct is a separate module.