This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-24
Channels
- # announcements (26)
- # babashka (9)
- # beginners (63)
- # calva (2)
- # chlorine-clover (22)
- # cider (2)
- # cljsrn (8)
- # clojure (36)
- # clojure-europe (36)
- # clojure-italy (5)
- # clojure-nl (76)
- # clojure-spec (9)
- # clojure-uk (8)
- # clojurescript (39)
- # conjure (24)
- # cursive (19)
- # data-science (1)
- # datascript (10)
- # datomic (1)
- # emacs (2)
- # events (5)
- # figwheel-main (9)
- # fulcro (21)
- # graalvm (1)
- # helix (5)
- # jobs (1)
- # jobs-discuss (1)
- # kaocha (1)
- # leiningen (4)
- # meander (2)
- # off-topic (22)
- # re-frame (16)
- # reitit (3)
- # rewrite-clj (75)
- # rum (1)
- # sci (51)
- # shadow-cljs (110)
- # tools-deps (16)
- # vrac (9)
- # xtdb (23)
For form validation in CLJS app, am I right in thinking I will need: • spec step for raw input strings - e.g. required but blank • transform step - e.g. "asdf" can't convert to number • spec step for converted data (not in range or otherwise logically invalid)
hi, try this https://clojure.wladyka.eu/posts/form-validation/ It can be helpful.
I wrote library https://github.com/kwladyka/form-validator-cljs for that purpose and here https://kwladyka.github.io/form-validator-cljs/ you have example of real code
Ok, cool. Thanks.
this is another cool library which can help you out https://github.com/alexanderkiel/phrase
Or I guess just not sure what is good practice there. Previously in F#, I wrote a very small lib to compose validations and/or type conversion. (Failing to type-convert as a validation error.)
Hmm, looks like maybe spec-tools or something like it is a common answer. https://cljdoc.org/d/metosin/spec-tools/0.10.4/doc/spec-coercion
Hi! Question regarding best practice around configuring values/constants based on deployment. I want to have a different value for variable/constant based on whether the clojurescript app is running in DEV v TEST v PROD. I am running re-frame. Any suggestions or pointers?
Thanks!
Is there a distinction in shadow-cljs
between a test release and a prod release? The only options seem to be :dev
and :release
, which means all release builds will use the same values.
If your test build must be sufficiently different from the dev build, then you can just add a new build configuration specifically for testing.
It’s different only in the :closure-defines
so it would be too much duplicate configuration to have the test
as its own config.
I don't know shadow-cljs that well to give a better answer - you should definitely ask in #shadow-cljs
I think you either have a very strange browser or something overrides the global console
object.
must be something with how or when Figwheel calls my on-jsload function. If I just add (js.console/clear)
to my "main" method it works
So I just added some specs into a clojurescript project, that uses (st/instrument)
to instrument the specs in dev.
This is in a browser, and the spec errors are almost unusable in the console — like far worse than clj is.
I’m currently using the binaryage/cljs-devtools
, and suspect that might be contributing to making them worse.
How do people get useful errors out of spec instrumentation in cljs?
I already include expound actually, thanks - i’ll give it a try
@rickmoynihan This ticket includes some code for an error formatter for devtools. https://github.com/bhb/expound/issues/152
ahh it’s the same as what I’ve already taken from the README 🙂 Thanks for the heads up though
If that doesn’t work for you, I’d be curious to see what you end up doing. I am interested in expanding the Expound documentation to include some additional ideas on this topic.
Hmmm I swear this was working yesterday, but today my spec errors aren’t being pretty printed 😕
I have:
(ns myapp.error-formatter
(:require [cljs.repl :as repl]
[expound.alpha :as expound]
[cljs.spec.alpha :as s :include-macros true]))
(set! s/*explain-out* expound/printer)
(println "error formatter set")
(def devtools-error-formatter
"Uses cljs.repl utilities to format ExceptionInfo objects in Chrome devtools console."
#js{:header
(fn [object _config]
(println "custom formatter called")
(when (instance? ExceptionInfo object)
(let [message (some->> (repl/error->str object)
(re-find #"[^\n]+"))]
#js["span" message])))
:hasBody (constantly true)
:body (fn [object _config]
#js["div" (repl/error->str object)])})
(defonce _
(some-> js/window.devtoolsFormatters
(.unshift devtools-error-formatter)))
in a namespace, and shadow-cljs incuding this via a preload:
:preloads [devtools.preload
myapp.error-formatter ;; <- pretty print spec errors with expound
myapp.front-end-specs ;; <- spec instrumentation
]
Ok I seemed to have an out dated install of cljs-devtools… upgrading seems to have fixed this
hmm… just tweaked a spec, and now getting:
Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required
reporter.cljs:32 In CLJS DevTools 1.0.0, an exception was raised during value formatting.
Error: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required
at eval (alpha.cljs:74)
at Object.eval [as cljs$core$IDeref$_deref$arity$1] (alpha.cljs:22)
at Object.cljs$core$_deref [as _deref] (core.cljs:686)
at Object.cljs$core$deref [as deref] (core.cljs:1475)
at Function.eval [as cljs$core$IFn$_invoke$arity$variadic] (alpha.cljs:74)
at Object.cljs$spec$gen$alpha$simple_type_printable [as simple_type_printable] (alpha.cljs:74)
at eval (alpha.cljs:90)
at Object.eval [as cljs$core$IDeref$_deref$arity$1] (core.cljs:10572)
at Object.cljs$core$_deref [as _deref] (core.cljs:686)
at Object.cljs$core$deref [as deref] (core.cljs:1475)
---
Please report the issue here:
I’m assuming this is because I have some fspec
s on some functions that are used in an fdef
I’d thought that cljs had stopped requiring you to use clojure.test.check generators 👀
https://clojurescript.org/news/2019-01-31-release ahh I guess you do require them if you have an fspec?
though I don’t define any :ret
specs
yeah ok just adding a require for clojure.test.check
fixes this