https://github.com/darky/gledo
Gleam decode Option
https://github.com/darky/gledo
decode gleam option
Last synced: 3 months ago
JSON representation
Gleam decode Option
- Host: GitHub
- URL: https://github.com/darky/gledo
- Owner: darky
- Created: 2024-05-12T16:01:21.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-12T20:25:17.000Z (about 2 years ago)
- Last Synced: 2025-10-09T13:07:59.766Z (8 months ago)
- Topics: decode, gleam, option
- Language: Gleam
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gledo
[](https://hex.pm/packages/gledo)
[](https://hexdocs.pm/gledo/)
Gleam decode Option
```sh
gleam add gledo
```
```gleam
import gledo
pub fn main() {
Some(123) |> dynamic.from |> gledo.decode_option // Ok(Some(123))
None |> dynamic.from |> gledo.decode_option // Ok(None)
123 |> dynamic.from |> gledo.decode_option // Error([DecodeError("Option", "Int", [])])
}
```
Further documentation can be found at .
## Why not stdlib dynamic.optional?
`dynamic.optional` from stdlib has permissive design and will successfully decode any value.
If need to have strict decoding for `Option` value only, feel free to use **gledo**
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```