This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-15
Channels
- # announcements (13)
- # aws (6)
- # babashka (23)
- # babashka-sci-dev (6)
- # beginners (64)
- # calva (110)
- # cider (25)
- # cljs-dev (5)
- # cljsrn (8)
- # clojars (5)
- # clojure (20)
- # clojure-austin (1)
- # clojure-europe (77)
- # clojure-nl (1)
- # clojure-uk (3)
- # clojurescript (14)
- # cursive (7)
- # datahike (9)
- # datomic (13)
- # eastwood (15)
- # emacs (14)
- # figwheel-main (1)
- # fulcro (8)
- # graalvm-mobile (2)
- # graphql (2)
- # honeysql (2)
- # hyperfiddle (2)
- # introduce-yourself (4)
- # jobs (4)
- # joyride (4)
- # leiningen (4)
- # lsp (8)
- # minecraft (8)
- # off-topic (11)
- # polylith (18)
- # rdf (2)
- # reagent (3)
- # reitit (4)
- # remote-jobs (1)
- # shadow-cljs (39)
- # specter (7)
- # xtdb (3)
I've got the string "\""
- an escaped quote. I need to escape this string so that it looks like this: "\\\""
, substituting \
-> \\
and "
-> \"
.
I've tried using (str/escape "\"" {"\\" "\\\\" "\"" "\\\""})
, but that just returns the input unchanged.
Because "\n"
is a newline character in a string. And \n
is an n
character.
To get a newline character, you need to use \newline
.
That's right, thanks. And I was able to handle /return
without any trouble too. My serialization tests are all passing now : )
I'm trying out (str/replace "\"" #"[\"\\]" #(println (pr-str %)))
, but it's printing out the whole escaped quote as well.
you don't need to string escape inside regex literals (you do need regex escapes)
Hi there, I rarely use conform
but today I was playing around and I have spec like
(s/def ::format-1.1.0
(s/or :ref string? :refs (s/* string?)))
Is there a way for conform
to avoid using the tag for it, e.g.:
[:refs
["foo" "bar"]]
and just get a plain ["foo" "bar"]
?yeah, you can wrap s/nonconforming
around it
Oh let me try that Alex, did not know it existed!
from what I've seen, the 99% use case for wanting this is s/or so we will probably at some point either make nonconforming actually documented or add an option or variant directly to s/or
Hi Alex, sorry back to this, I tried and I see s/nonconforming
is applied to all the children, is there a way to avoid that for some of them?
Oh ok I randomly wrapped the children with s/spec
makes them "conforming" again and it worked
(s/def ::user-or-users
(s/nonconforming
(s/or :user (s/spec :data-export.user/format-1.1.0)
:users (s/* (s/spec :data-export.user/format-1.1.0)))))
I am not this can be improved, I'll post it in the main channel as well :Dooops no sorry it does not
kind of stuck on this for now, I'll pick this back up prolly on Monday, thanks in advance for any comment/improvement
;; DONT s/nonconforming here would apply to the children and we don't want that
(s/def ::user-or-users
(s/or :user :data-export.user/format-1.1.0
:users (s/* (s/spec :data-export.user/format-1.1.0))))
(s/def ::format-1.1.0
(s/cat :diagnostic-report.status-code (s/nilable string?)
:diagnostic-report.primary-reader (s/nilable (s/spec :data-export.user/format-1.1.0))
:diagnostic-report.assisting-readers ::user-or-users
:diagnostic-report.overall-impressions (s/nilable string?)))
Oh ok I randomly wrapped the children with s/spec
makes them "conforming" again and it worked
(s/def ::user-or-users
(s/nonconforming
(s/or :user (s/spec :data-export.user/format-1.1.0)
:users (s/* (s/spec :data-export.user/format-1.1.0)))))
I am not this can be improved, I'll post it in the main channel as well :D