Fork me on GitHub
#malli
<
2021-11-18
>
rovanion15:11:32

I'm having trouble finding from-ast in malli.core. When I go to source in Emacs I get to 0.7.0-SNAPSHOT, so it should be the right version of the library that's loaded. But I can only see the name declared, never see it def'd.

ikitommi15:11:36

released most likely next week. You can take the latest sha from master with deps if you want to test it

rovanion16:11:17

Sorry, on Leiningen. Will the AST behave like the vector based schemas? That is: Print like a vector/map but not implement ISeq/Associative? What I'm really after is using the Malli schemas I've written to generate some Simple HTML forms.

ikitommi16:11:08

Sounds cool, there are multiple ways to walk the schemas for that: 1. use m/walk, look for json schema ns for example how to use it 2. use malli.util/subschemas to get the expanded list of the schema tree. Added that from a malli->form use case 😉

ikitommi16:11:32

on lein, can't use AST yet, sorry

ikitommi16:11:46

AST is just clojure maps

ikitommi06:11:47

refreshed the latest SNAPSHOT with all stuff in:

➜  ~ clj -Sforce -Sdeps '{:deps {metosin/malli {:mvn/version "0.7.0-SNAPSHOT"}}}'
Downloading: metosin/malli/0.7.0-SNAPSHOT/malli-0.7.0-20211118.202503-4.pom from clojars

rovanion09:11:53

Hmm, I get an exception thrown at me when loading malli in my project with this latest snapshot:

#error {
 :cause No such var: mr/fast-registry
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message Syntax error compiling at (tove/core.clj:1:1).
   :data #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source tove/core.clj}
   :at [clojure.lang.Compiler load Compiler.java 7652]}
  {:type java.lang.ExceptionInInitializerError
   :message nil
   :at [java.lang.Class forName0 Class.java -2]}
  {:type clojure.lang.Compiler$CompilerException
   :message Syntax error compiling at (malli/core.cljc:2362:53).
   :data #:clojure.error{:phase :compile-syntax-check, :line 2362, :column 53, :source malli/core.cljc}
   :at [clojure.lang.Compiler analyze Compiler.java 6812]}
  {:type java.lang.RuntimeException
   :message No such var: mr/fast-registry
   :at [clojure.lang.Util runtimeException Util.java 221]}]
But I don't get the same exception when just requiering malli.core in an empty project with just malli and clojure declared as dependencies.

Yehonathan Sharvit15:11:47

How can I define a custom predicate? E.g. a string of length 5 (or another more advanced logic).

Yehonathan Sharvit15:11:52

I tried the following

Yehonathan Sharvit15:11:00

[:map {:registry {:asset-id [:and :string #(= 5 (count %))]}}
  [:aa :asset-id]]

Yehonathan Sharvit15:11:09

But malli says that the schema is not valid

ikitommi15:11:51

@viebel wrap custom fns in :fn

ikitommi15:11:01

also, [:string {:max 6}]