This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-25
Channels
- # announcements (6)
- # asami (1)
- # babashka (80)
- # beginners (89)
- # bitcoin (1)
- # calva (30)
- # cider (33)
- # clj-kondo (1)
- # cljsrn (45)
- # clojars (5)
- # clojure (60)
- # clojure-australia (1)
- # clojure-dev (9)
- # clojure-europe (133)
- # clojure-italy (7)
- # clojure-nl (6)
- # clojure-uk (44)
- # clojurescript (11)
- # conjure (1)
- # data-oriented-programming (2)
- # datahike (13)
- # datascript (4)
- # datomic (19)
- # deps-new (29)
- # depstar (5)
- # duct (39)
- # fulcro (8)
- # girouette (1)
- # helix (10)
- # honeysql (17)
- # jobs (5)
- # jobs-discuss (2)
- # leiningen (6)
- # lsp (51)
- # malli (60)
- # meander (37)
- # membrane (8)
- # off-topic (31)
- # overtone (3)
- # pathom (36)
- # re-frame (8)
- # reagent (30)
- # remote-jobs (2)
- # sci (1)
- # sql (32)
- # startup-in-a-month (3)
- # testing (3)
- # tools-deps (7)
- # xtdb (7)
In the clojure.tools.cli lib you can provide a tuple of [validation-fn msg]
. If validation-fn
was, say, (fn [input] (s/valid? ... ...))
we currently have no way of making the error message dependent on the input, as its a hardcoded string. Would an issue / patch be welcome to extend the second option to a function, so we can have (fn [input] (s/explain ... ...))
there?
E.g. for malli I would like to do this:
(def cli-options
[["-n" "--number NUM" "A number"
:parse-fn (m/decoder int? mt/string-transformer)
:validate [(fn [input]
(m/validate [:< 100] input))
(fn [input]
(me/humanize (m/explain [:< 100] input)))]]])
Create a Jira if you have permission or else put it on http://ask.clojure.org - I'm not averse to the idea but would need to analyze it in more depth first. I've never much liked that tuple approach.
Good job you remembered to post it there -- I'd already forgotten 🙂
Until I double-checked, I thought it was the other comment!