Renamed to bellroy/elm-parse-dont-validate. It is published under that name, and new versions come out there.
Versions published as tricycle/elm-parse-dont-validate still install under that name. 1 version of 1 come from the new location (see their notes).
Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.
What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/tricycle/elm-parse-dont-validate/zipball/1.0.0/
This library provides a bunch of parser combinators and could be used for Web form validation.
It follows ideas described here: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validateBy/
Given a non-empty list of uniform parsers returns a parser that produces a non empty list of their results. If any of the provided parsers fails - resulting parser also fails.
Parser composition: result produced by second parser is fed to the first
Useful for a "pipeline" style:
example : Parser { bar : String, baz : String } Error Foo
example =
succeed (\a b -> Foo a b)
|> by .bar parseBar
|> by .baz parseBazMaps over Parser input
Returns error
Create Parser from function of type inp -> Maybe out
Maps over parser result
Maps over parser error
When given a function that merges parsing results and two parsers producing such results - returns a parser that produces a result of that function.
Returns successfully parsed value
Syntactic abstraction: applies parser to its input
Useful for a "pipeline" style:
example : Parser { bar : String, baz : String } Error Foo
example =
succeed (\a b -> Foo a b)
|> by .bar parseBar
|> by .baz parseBaz
|> validateBy identity barBazParserUseful for a "pipeline" style when validator emits an error message but reurns () in order not to consume constructor argument:
example : Parser { bar: String, baz: String } Error Foo
example =
succeed (\bar baz -> Foo bar baz)
|> by .bar parseBar
|> by .baz parseBaz
|> validateBy identity barBazParser
barBazParser : { bar: String, baz: String } Error Unit
barBazParser { bar, baz } =
if bar /= baz
then Parser.fail "Bar != Baz"
else Parser.ok ()Create Parser from predicate function that returns a wrapped input value. Parser fails with provided error in case if predicate evaluates to False.
Given 2 parsers, feeds same input into both of them and returns results as tuple
Given a parser without error decorates it with an error provided
Parser type
inp Input type (what is parsed/validated) err Error type (Could be your custom error type) out Output type (Could be your domain type)