Hacker News new | ask | show | jobs
by nesarkvechnep 1254 days ago
I like to use changesets for form validation, for example, but those changesets are different than the ones I use in my public API functions. Most of the time what I present to the user don’t map 1:1 to my Ecto schemas and it doesn’t have to.
1 comments

This is going to be an unpopular opinion, but I think it's unfortunate that changesets are tied to the views in Phoenix. It's major leakage of ecto and the inner domain at best and at worst it intertwines various concerns - validation and what's changing. The naming of it gives that design choice away. It it didn't it would probably have a name with "validation" in it somewhere. I'd much rather have domain structs implement a protocol. Maybe that's possible I haven't really looked into it.

However, what you say about having different changesets for validation seems to make a ton of sense to me and has given me some ideas. Thanks.