I want to set a value uuid for a new record. I created a util function that read type of changeset action and sets the value in changeset.
The issue is that I want to set the value in schema module in changeset f, so it is a central location for population of fields.
The thing is that in a standard code action is set only after the Repo insert is executed.
def changeset(client, attrs) do
client
|> cast(attrs, [:uuid, :name])
|> DataUtils.set_uuid
...
def set_uuid(changeset) do
if get_change(changeset, :insert) do
uuid = Ecto.UUID.generate
...