getto-systems/elm-url/1.0.0

Getto.Url.Query.SafeDecode

decode url query string safety

value = "count=4&position[]=captain&admin" |> QuerySafeDecode.split


value |> QueryDecode.entryAt ["count"]    (QuerySafeDecode.int 0)
value |> QueryDecode.listAt  ["position"] (QuerySafeDecode.string "")
value |> QueryDecode.boolAt  ["admin"]

Definition

type alias Value =
Value

decode target : actually this is List String

type alias Decoder a =
Value -> a

decoder : Value -> Maybe a

Decoders

string : String -> ValueDecoder String

string decoder

int : Int -> ValueDecoder Int

int decoder

Decode

entryAt : List String -> ValueDecoder a -> Decoder a

decode entry

listAt : List String -> ValueDecoder a -> Decoder (List a)

decode list

boolAt : List String -> Decoder Bool

decode bool

Helper

split : String -> Value

query string to Value

"name=John&position=captain" |> QuerySafeDecode.split
-- [ "name=John", "position=captain" ]