Pattern match changeset function to accept only specific type?

Is this correct?

def changeset(%MyApp.User{} = struct, params) do
  # snip
end

I’m trying to write the changeset function to only accept a struct of type MyApp.User.

Thanks!

1 Like

Seems to be correct.

2 Likes

Yeah that looks correct. Although sometimes it is also useful to be able to pass a changeset to your changeset functions so that you can compose them. Although that isn’t something that you’ll be doing until you have multiple changeset functions on one schema/model.

2 Likes