Fork me on GitHub
#malli
<
2024-02-22
>
Joel03:02:50

[:schema {:registry registry} attribute]
Does attribute have to be a qualified-keyword?

ikitommi07:02:01

(m/validate 
 [:schema {:registry {"kikka" :int
                      :kukka :int
                      ::kakka :int
                      'kokka :int
                      `kekka :int}}
  [:tuple "kikka" :kukka ::kakka 'kokka `kekka]]
 [1 2 3 4 5])
; => true

ikitommi07:02:14

if you use references, it has type constraints:

((requiring-resolve 'malli.dev/start!))

(m/schema [:ref :kukka])

; => 

-- Schema Error ------------------------------------------------- Thread:1583 --

Invalid Reference

  [:ref :kukka]

Reason

  Reference should be one of the following

  - a qualified keyword, [:ref :user/id]
  - a qualified symbol,  [:ref 'user/id]
  - a string,            [:ref "user/id"]
  - a Var,               [:ref #'user/id]

More information

  

--------------------------------------------------------------------------------
Execution error (ExceptionInfo) at malli.core/-exception (core.cljc:136).
:malli.core/invalid-ref

thanks3 1
BBTiger Michael06:02:42

@ikitommi Hi,I feel wonderful to read https://www.metosin.fi/blog/transforming-data-with-malli-and-meander and I have a question about what tool was used to get this picture.

ikitommi07:02:45

thanks! can’t recall, but first thing that the google found, was not a good experience, was throwaway code. Today, I would use https://reactflow.dev/ for that.

2
👍 2
Sam13:02:50

Is there a way to make this work? Based on https://github.com/metosin/malli/blob/master/docs/function-schemas.md#function-schemas-1

(=> foo [:=> [:cat :int] :int [:fn (fn [[arg] ret] (= 10 ret))]])
(defn foo [x]
  10) 
;; errors with Schema has 3 children, expected {:max 2, :min 2}

juhoteperi13:02:18

Seems like tests don't have any test cases for that, so I wonder if the doc just has a issue mentioning a non existing feature

juhoteperi13:02:58

Oh that line was added just last month to the docs

juhoteperi13:02:37

Yeah that feature isn't on 0.14

Sam14:02:38

Cool! Something to look forward to 🙂