Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #925 #926

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ We use [Break Versioning][breakver]. The version numbers follow a `<major>.<mino

Malli is in well matured [alpha](README.md#alpha).

## UNRELEASED

* FIX: retain order with `:catn` unparse, fixes [#925](https://github.com/metosin/malli/issues/925)

## 0.11.0 (2023-04-12)

* BREAKING: remove map syntax: `mu/from-map-syntax`, `mu/to-map-syntax`. Note that AST syntax and lite syntax remain unchanged.
Expand Down
2 changes: 1 addition & 1 deletion src/malli/impl/regex.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
:malli.core/invalid))))

(defn catn-unparser [& unparsers]
(let [unparsers (into {} unparsers)]
(let [unparsers (apply array-map (mapcat identity unparsers))]
(fn [m]
(if (and (map? m) (= (count m) (count unparsers)))
(miu/-reduce-kv-valid (fn [coll tag unparser]
Expand Down
15 changes: 15 additions & 0 deletions test/malli/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2959,3 +2959,18 @@
(prefixer "g")
(prefixer "h")
(prefixer "i")) "xxx"))))))

(deftest -issue-925-test
(testing "order is retained with catn parse+unparse"
(let [schema [:catn
[:a :int]
[:b :int]
[:c :int]
[:d :int]
[:e :int]
[:f :int]
[:g :int]
[:h :int]
[:i :int]]
input [1 2 3 4 5 6 7 8 9]]
(is (= input (->> input (m/parse schema) (m/unparse schema)))))))