This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-19
Channels
- # announcements (24)
- # asami (25)
- # babashka (17)
- # beginners (99)
- # bitcoin (1)
- # calva (2)
- # cider (6)
- # cljs-dev (4)
- # clojure (88)
- # clojure-australia (3)
- # clojure-europe (23)
- # clojure-france (6)
- # clojure-nl (5)
- # clojure-uk (31)
- # clojured (1)
- # clojurescript (6)
- # clojureverse-ops (1)
- # datomic (28)
- # depstar (18)
- # emacs (11)
- # events (1)
- # fulcro (21)
- # graalvm (4)
- # graphql (7)
- # heroku (1)
- # jackdaw (18)
- # joker (3)
- # kaocha (1)
- # lsp (1)
- # malli (13)
- # meander (4)
- # off-topic (12)
- # pathom (14)
- # pedestal (2)
- # podcasts-discuss (1)
- # re-frame (37)
- # reagent (17)
- # reitit (9)
- # shadow-cljs (44)
- # xtdb (17)
I'm trying to create a schema for a CSV data structure with defined, case insensitive headers. It must also be able to generate a legal data structure. I'm using the same pattern as clojure.data.csv
, a vector of vectors with the first vector representing the headers and the remaining vectors representing the rows. I can create a schema for the headers that checks validity fairly simply
(def headers
[:cat
[:re "(?i)header1"]
[:re "(?i)header2"]
...
[:re "(?i)headerN"]])
But test.chunk
doesn't handle flags (the (?i)
bit), so I don't have a generator.
My next guess is to create a schema that can match a given string case-insensitively and then a generator that will generate a randomly cased version of that string. I can write these two functions, but can't work out how to create a schema with them. Any thoughts or docs you can point me to?Aha! Awesome, thanks for the quick reply :thumbsup:
@ikitommi I also have several malli schemas that need to verify for [:fn (complement str/blank)]
and I saw an open discussion from some years ago in Malli about adding validation of stripped strings to [:string]
base schema
not some years.. last year, sorry. thought was 2019 https://github.com/metosin/malli/pull/205
or:
[:map {:registry {::non-blank-string [:string {:min 1}]}}
[:name ::non-blank-string]
[:address [:map [:street ::non-blank-string]]]]