Replies: 1 comment 1 reply
-
Thanks, for now let me just paste what I wrote in this reddit comment:
Correct, standalone validators that are not tied to persistence is what schemaless Ecto changesets provide. There are similar benefits of using both changesets and contracts. It's the approach to solving this problem that makes the experience different. Like I said, one needs to decide what works better. I can provide comparisons to explain this in code, I just didn't want to make it one vs the other, so I decided not to mention Ecto in the first announcement post. Now I feel like I need to do this though 😀
The rule macro defines a corresponding
In case of Contracts atomization is automatic and works OOTB even with deeply nested schemas including things like lists of lists of schemas and other fun data structures, so I don't think it's the same as in Ecto.
The practical aspect of this approach is that you know what went wrong. Sometimes it doesn't matter, sometimes it does, it's just nice to have the option to validate before casting. Another great aspect of this is that casting functions can be simpler, because they don't need to be defensive, their input is type-safe. |
Beta Was this translation helpful? Give feedback.
-
Hey 👋
This library looks interesting but I cannot help but wonder how it compares to using Ecto to validate data. At first glance it looks to provide very similar functionality.
I'm not familiar with the Ruby version this is ported from so maybe its purpose is to have an Elixir alternative for people transitioning from Ruby.
Thank you for being a part of the Elixir ecosystem and best of luck!
Beta Was this translation helpful? Give feedback.
All reactions