revati
Determine type with NimbleParsec?
i want to parse string and determine if value is string/number/boolean/date/time/datetime/probably many more distinct value value types in future.
How to approach this. do i create parse for each separate option and than one choice?
But i have this caveat. for example for boolean, either it is word true or number 1 they can be casted to string or number respectively. Workaround for this might be, that seems ok from business point of view to have prefix or suffix, like boolean:1 or 1:boolean. and if this type casting prefix/suffix is present force that type for parser.
I don’t understand nimble parsec at that level, but i believe prefix is a lot easier (but still pretty hard - at least for me), but bossiness much rather would prefer suffix ![]()
someStringValue → string someStringValue
1 → integer 1
1.4 → float 1.4
1.4:string → string 1.4
1:boolean → boolean true
etc. If you have some hints, ideas how to approach this, i would greatly appreciate it.
Most Liked
LostKobrakai
I’d separate parsing the string to tokens of interest and then bringing those tokens together with whatever business logic you have around it.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









