Skip to content

Commit 3a5d796

Browse files
committed
Decode path tags helper
1 parent 026314e commit 3a5d796

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Lib/Util.elm

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module Lib.Util exposing (..)
22

33
import Http
44
import Json.Decode as Decode
5+
import Json.Decode.Extra exposing (when)
56
import List.Nonempty as NEL
67
import Process
78
import Task
@@ -90,6 +91,16 @@ decodeTag =
9091
Decode.field "tag" Decode.string
9192

9293

94+
whenTagIs : String -> Decode.Decoder String -> Decode.Decoder String
95+
whenTagIs val =
96+
whenPathIs [ "tag" ] val
97+
98+
99+
whenPathIs : List String -> String -> Decode.Decoder String -> Decode.Decoder String
100+
whenPathIs path val =
101+
when (Decode.at path Decode.string) ((==) val)
102+
103+
93104
decodeUrl : Decode.Decoder Url
94105
decodeUrl =
95106
let

0 commit comments

Comments
 (0)