metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.43k stars 204 forks source link

Fix fn guard default configuration #1017

Closed allentiak closed 3 months ago

allentiak commented 3 months ago

Current default does not include the new fn guard. Fixes #1018

NoahTheDuke commented 3 months ago

Looks like your merge wasn't successful, so there are no changes present in the PR. Might want to rebase/rollback that commit.

allentiak commented 3 months ago

@NoahTheDuke Thanks for the comment.

Yeah, it seems the Codespace in which I started working used an old commit as a baseline... It seems I will have to start editing from scratch again...

I guess automatically generated web environments are not perfect?

BTW: @ikitommi in an earlier commit on this file (https://github.com/metosin/malli/commit/3b73f64d00e14593f9c47fd546eb32d159fe8a4c) you did use the "guard" as a default parameter when validating. Why did you change your mind later?

ikitommi commented 3 months ago

not sure what is the queestion here. Here's how it works now:

(m/=> kikka6 [:=>
              [:cat :int]
              :int
              [:fn {:error/message "input should be output"}
               (fn [[[arg] ret]] (= arg ret))]])
(defn kikka6 [x] (inc x))

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

(kikka6 1)

gives:

-- Function Guard Error ----------------------------------------- Thread:1583 --

Function Var

  malli.core-test/kikka6

Guard arguments

  [[1] 2]

Guard Schema

  [:fn
   {:error/message "input should be output"}
   #object["malli.core_test$eval17032$fn__17034@1803b826"]]

Errors

  {:in [],
   :message "input should be output",
   :path [],
   :schema [:fn
            {:error/message "input should be output"}
            #object["malli.core_test$eval17032$fn__17034@1803b826"]],
   :value [[1] 2]}

More information

  https://cljdoc.org/d/metosin/malli/CURRENT/doc/function-schemas

--------------------------------------------------------------------------------
allentiak commented 3 months ago

Hi, Thanks for the message, @ikitommi You're right: my bad. Sorry for the misunderstanding. Closing...