Comments (2)
Interesting. All schemas run both :decode
and :encode
in children in same order. I also think this is wrong. I need to revisit the ordering, thanks for reporting.
Tested with a dirty (and invalid) fix:
diff --git a/src/malli/core.cljc b/src/malli/core.cljc
index d66b3f9..a2b3b1e 100644
--- a/src/malli/core.cljc
+++ b/src/malli/core.cljc
@@ -519,7 +519,8 @@
(defn -parent-children-transformer [parent children transformer method options]
(let [parent-transformer (-value-transformer transformer parent method options)
child-transformers (into [] (keep #(-transformer % transformer method options)) children)
- child-transformer (when (seq child-transformers) (apply -comp (rseq child-transformers)))]
+ mapper (if (= :encode method) identity rseq)
+ child-transformer (when (seq child-transformers) (apply -comp (mapper child-transformers)))]
(-intercepting parent-transformer child-transformer)))
.. which gives "correct" order/results for this case but doesn't solve the whole problem.
from malli.
Documenting to myself, current order on decode:
(let [log (atom [])
log! (fn [s p] (fn [x] (swap! log conj [(:i (m/properties s)) p]) x))]
(m/decode
[:map {:i 0}
[:x {:i 1} [:int {:i 2}]]
[:y {:i 3} [:string {:i 4}]]
[:z {:i 5} [:maybe {:i 6} [:and {:i 7}
[:keyword {:i 8}]
[:or {:i 9}
[:string {:i 10}]
[:qualified-keyword {:i 11}]]]]]]
{:x 1
:y "kikka"
:z :kikka/kukka}
(mt/transformer
{:default-decoder {:compile (fn [schema _]
{:enter (log! schema :enter)
:leave (log! schema :leave)})}}))
@log)
;[[0 :enter]
; [1 :enter]
; [2 :enter]
; [2 :leave]
; [1 :leave]
; [3 :enter]
; [4 :enter]
; [4 :leave]
; [3 :leave]
; [5 :enter]
; [6 :enter]
; [7 :enter]
; [8 :enter]
; [8 :leave]
; [9 :enter]
; [10 :enter]
; [10 :leave]
; [11 :enter]
; [11 :leave]
; [9 :leave]
; [7 :leave]
; [6 :leave]
; [5 :leave]
; [0 :leave]]
from malli.
Related Issues (20)
- Invalid Swagger JSON with [:or :nil] alternatives HOT 1
- Feature: Using Java classes as schemas HOT 2
- Not supported 3.1.0 openapi schema HOT 1
- Is it possible to represent an increasing sequence? HOT 1
- Parser losing metadata? HOT 1
- function guard should be instrumented by default HOT 1
- Nested map destructuring in `mx/defn` wraps extra collection
- qualified keywords in :keys in mx/defn fails macro schema validator. HOT 2
- `:double` generates Long if `:min` is Long
- `[:> Double/MAX_VALUE]` generates `Double/MAX_VALUE`
- Cannot generate values for regular expression schema HOT 2
- Function generators return constant function if seed provided
- Malli doesn't work with latest Cherry HOT 1
- A composite registry cannot be used a local registry HOT 1
- allow :error/fn or :error/message in {:optional t/f} to help define missing key error message
- How to: specify SCI `:classes`
- Datafy representation for reified schemas
- Add :min/:max limits to :map validator
- plantuml and dot transform fail with custom registry HOT 1
- OutOfMemoryError Java heap space exhausted with wrong schema
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from malli.