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)
Not yet, but feel free to post an issue, so we can gather community feedback. Meanwhile there are two options: spartan.spec and minimallist both work
there is https://github.com/metosin/malli/issues/302. Help most welcome
I think it will be quite a lot of work to port malli to bb compatible code. @ikitommi What is the API stability of malli? At one point we could add it to bb proper perhaps. I want to consider this, but also want some feedback from the "bb community" on this
thanks guys. since it’s only tools.cli in CI (i.e. almost never changes), I can write a custom vaildator instead
@U0510KXTU OK. This lib https://github.com/green-coder/minimallist also works with bb btw
I like that it explicitely does not try to be fast. probably means they can deliver features faster
perf is a feature and the style of writing code (reifying Java classes) isn't well supported by bb from source for any Java class :)
yes. in the malli repo, write a script like:
(require '[babashka.classpath :as cp])
(cp/add-classpath "src")
and then
(require '[malli.core :as m])
@ikitommi Actually, this is better:
(ns bb-script)
(require '[babashka.deps :as deps]
'[clojure.edn :as edn])
(deps/add-deps (edn/read-string (slurp "deps.edn")))
(require '[malli.core :as m])
@ikitommi So the first hack I did:
(ns malli.sci
#?@(:bb [] :clj [(:require [borkdude.dynaload :as dynaload])]))
(defn evaluator [options fail!]
#?(:bb fail! :clj
(let [eval-string* (dynaload/dynaload 'sci.core/eval-string* {:default nil})
init (dynaload/dynaload 'sci.core/init {:default nil})
fork (dynaload/dynaload 'sci.core/fork {:default nil})]
(fn [] (if (and @eval-string* @init @fork)
(let [ctx (init options)]
(fn eval [s] (eval-string* (fork ctx) (str s))))
fail!)))))
The nest error:
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Unable to resolve classname: java.util.ArrayDeque
Location: /private/tmp/malli/src/malli/impl/regex.cljc:35:3
----- Context ------------------------------------------------------------------
31: recognition for `validate`."
32:
33: (:refer-clojure :exclude [+ * repeat cat])
34: (:require [malli.impl.util :as miu])
35: #?(:clj (:import [java.util ArrayDeque])))
^--- Unable to resolve classname: java.util.ArrayDeque
Then after doing that, I run into:
(deftype ^:private CacheEntry [^long hash f ^long pos regs])
So these are the types of things that are not supported yet. Classes can be added, but deftype
isn't supported.
I don't know what to do with deftype yet. Records are "faked" using normal maps + metadata.
I have seen a similar thing with meander vs matchete. Matchete is written in a "simple" Clojure style so it just works with bb out of the box. https://github.com/xapix-io/matchete Where meander focuses on performance and this results in incompatible code.
Meander now has an "interpreter" which is compatible with bb which also more flexible than the macro style enforced in the main lib
Is there a way to get the humanized string for a schema, without any input?
(prn (me/humanize [:< 100]))
;;=> "should be smaller than 100"
you can either:
[:int {:max 100}]
or:
[:< {:error/message "should be smaller than 100"} 100]
might map all predicates schemas into these internally, which would make things like JSON Schema transformations & normal transformations simpler, need just to be defined for the base type, not to all predicates.
@ikitommi What I mean is: you can get a string from humanize
but this needs some input too which you first have to validate. However, the resulting string doesn't seem to be related to the input at all. This made me wonder: is it possible to get some "model" error message from a schema only, without validating anything
Not that important, I can make the string itself manually or by validating some dummy input
malli supports both fixed error messages and functions generating error messages, the two examples here: https://github.com/metosin/malli/blob/master/src/malli/error.cljc#L62-L68