This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-16
Channels
- # beginners (176)
- # boot (11)
- # cider (12)
- # cljs-dev (65)
- # cljsrn (54)
- # clojars (18)
- # clojure (195)
- # clojure-austin (1)
- # clojure-dev (2)
- # clojure-italy (8)
- # clojure-quebec (1)
- # clojure-russia (51)
- # clojure-serbia (3)
- # clojure-spec (24)
- # clojure-uk (28)
- # clojurescript (41)
- # cursive (14)
- # data-science (60)
- # datascript (2)
- # datomic (111)
- # emacs (6)
- # figwheel (1)
- # graphql (16)
- # hoplon (26)
- # juxt (2)
- # lein-figwheel (3)
- # lumo (12)
- # off-topic (8)
- # om (14)
- # pedestal (22)
- # perun (2)
- # proton (1)
- # re-frame (29)
- # reagent (27)
- # ring (17)
- # ring-swagger (2)
- # rum (3)
- # spacemacs (3)
- # unrepl (155)
- # untangled (28)
- # vim (4)
That the incoming values will be in that set when conformed, and that strings will be conformed to keywords.
(def vs #{:some :specific :values}) (s/def ::example (into vs (map name) vs))
That doesn't conform to keywords but transformation is not really the point of spec
does anyone know of any efforts that present clojure spec validation errors in a nice way? I’m looking for ideas and inspiration for a web based error message component I’m working on
@odinodin just spent some time looking into the same issue, found this https://www.slideshare.net/alexanderkiel/form-validation-with-clojure-spec and can recommend this approach
@rmuslimov thanks. I was thinking more about how to present raw clojure.spec validation errors in a nicer way during development
ah ok, interesting. Not sure how standard can be improved, may be you already have any ideas - how it may look like?
urbank: https://groups.google.com/forum/?__s=f7szr7fg4jw7kzeciy43#!msg/clojure/10dbF7w2IQo/ec37TzP5AQAJ
Any news on https://dev.clojure.org/jira/browse/CLJ-2123 or something similar? Having some issues right now with name clashes on specs (that we still want in the same file). We're specing a re-frame db and want to keep the specs for a specific page in the same file. Often parts of specs for input field and similar end up having the same names as other parts of the state. The solution right now is either to create an artificial and verbose namespaced keyword (:my-page.input.domain/id) or to add a new file just for the clashing specs.
@curlyfry in a similar vein: when you refactor clashing keywords to have different namespaces, does the rename mean that you get rippling changes throughout your code?
I've got a map where all entries should follow some template (e.g. (s/map-of string? number?)
except one optional key, let's call it :foo
.
I tried something like s/merge
, but it seems like it was designed with multiple s/keys
specs in mind.
(s/merge (s/map-of string? number?) (s/keys :opt-un [::foo]))
.
I can of course write my own predicate function to split the map in two and check against each spec with s/valid?
, but I'll lose a lot of contextual information in case of failures.
Is there no better way ?
@pseud you can use the “hybrid map” technique that I describe at http://blog.cognitect.com/blog/2017/1/3/spec-destructuring
yours is a bit simpler than the one described there
@alexmiller cool, a bit too tired to digest, but bookmarked.