Skip to content

Commit

Permalink
try var roundrobin
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Jan 5, 2024
1 parent cb344ee commit e84aae5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/malli/edn.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[malli.core :as m]))

(defn -parse-string [x]
(edamame/parse-string x {:dispatch {\# {\" #(re-pattern %)}}}))
(edamame/parse-string x {:var resolve, :regex true, :fn true}))

(defn write-string
([?schema]
Expand Down
22 changes: 20 additions & 2 deletions test/malli/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,7 @@
(prefixer "h")
(prefixer "i")) "xxx"))))))

(deftest -issue-925-test
(deftest issue-925-test
(testing "order is retained with catn parse+unparse"
(let [schema [:catn
[:a :int]
Expand All @@ -2992,7 +2992,7 @@
input [1 2 3 4 5 6 7 8 9]]
(is (= input (->> input (m/parse schema) (m/unparse schema)))))))

(deftest -issue-937-test
(deftest issue-937-test
(testing ":altn can handle just one child entry when nested"
(let [schema [:* [:altn [:a [:= :a]]]]
value [:a]]
Expand All @@ -3001,3 +3001,21 @@
(is (= [[:a :a]] (m/parse schema value)))
(is (= value (m/unparse schema (m/parse schema value))))
(is (= value (m/decode schema value nil))))))

(def UserId :string)

(def User
[:map
[:id #'UserId]
[:friends {:optional true} [:set [:ref #'User]]]])

(deftest roundrobin-var-references
(let [registry (mr/composite-registry
(m/default-schemas)
(mr/var-registry))
options {:registry registry}
schema (m/schema User options)]
(is (as-> schema $
(edn/write-string $)
(edn/read-string $ options)
(every? (m/validator $) (mg/sample schema))))))

0 comments on commit e84aae5

Please sign in to comment.