Skip to content

darky/gledo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gledo

Package Version Hex Docs

Gleam decode Option

gleam add gledo
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 https://hexdocs.pm/gledo.

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

gleam run   # Run the project
gleam test  # Run the tests
gleam shell # Run an Erlang shell

About

Gleam decode Option

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages