bencoppock
I write about the frustration that can occur when dealing with string and atom-based keys in maps and how to (safely) translate string-based map keys to atoms:
Trending in Blog Posts
TL;DR: Give https://cure-lang.org a try—perhaps you will like it.
New
I finally found time to write down my journey away from ExMachina, including the workaround I tried first and the API experiments that fo...
New
The words are insufficient to describe what transpired. What we tried to do met what the people wanted it to be. It became beautiful.
Th...
New
Hi everyone,
I’ve been building BetterTyping (https://bettertyping.org) on and off since 2021. It’s a free typing game: practice alone, ...
New
Turns out a 1ms network hiccup is enough to silently lose broadcasts for a node and that node is just quietly wrong forever
Wrote it up ...
New
If you’ve found an interesting or cool Elixir related blog post and think it’s worth sharing please add it to this thread :icon_biggrin: ...
New
The code in this post is Erlang, but it all applies to Elixir binaries just the same: how appends, match contexts and sub-binaries behave...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
D4no0
Isn’t it easier to translate all keys to string, I don’t see any downsides for that as cast/4 casts required params.
derpycoder
Thanks for the writeup, learnt a lot. Ability to use when in anonymous function was enlightening.
I am learning Elixir, and thought I would give list comprehension a try:
I will never mixup the two, anything external will always be string, and hand written values will be atoms.
bencoppock
Makes sense to me!
Assuming you just want to translate the params to be atom-based (and you’re not directly creating a record with Ecto), are you thinking something like this…?
I imagine that working well if you have Ecto in the mix and don’t need to give feedback on invalid params.
gregvaughn
I would be looking at
Ecto.Changeset.apply_action/2to return either{:ok, struct}or{:error, changeset}which contains errors in the 2nd case. But it certainly depends on ecto (though not ecto_sql).bencoppock
I wasn’t writing this with Ecto in mind, but I usually do have Ecto in the mix, so I like that.
It also feels cleaner to use the return of the
apply_actionfunction (which can include validation errors) as opposed to directly relying on thechangesfield in the Changeset struct (even though I think the field is more or less considered “public”).