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

Inspectable interceptors #1160

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Inspectable interceptors #1160

wants to merge 14 commits into from

Conversation

ikitommi
Copy link
Member

test how to inspect interceptor chain:

;; tune the chain so that we get data tap>'ed
((requiring-resolve 'malli.dev/-capture-interceptor))

;; add a tap
(add-tap (fn [x] (clojure.pprint/pprint (update x :schema m/type))))

run an interceptor chain:

(def Address
  [:map
   [:id string?]
   [:tags [:set keyword?]]
   [:address
    [:map
     [:street string?]
     [:city string?]
     [:zip int?]]]])

(m/decode
 Address
 {:id "Lillan",
  :tags ["coffee" "artesan" "garden"],
  :address {:street "Ahlmanintie 29"
            :city "Tampere"
            :zip 33100}}
 (mt/json-transformer))
;{:id "Lillan"
; :tags #{:coffee :artesan :garden}
; :address {:street "Ahlmanintie 29"
;           :city "Tampere"
;           :zip 33100}}

... and see steps tapped:

{:schema :set,
 :name :json,
 :phase :enter,
 :input ["coffee" "artesan" "garden"],
 :output #{"coffee" "garden" "artesan"}}

{:schema keyword?,
 :name :json,
 :phase :enter,
 :input "coffee",
 :output :coffee}

{:schema keyword?,
 :name :json,
 :phase :enter,
 :input "garden",
 :output :garden}

{:schema keyword?,
 :name :json,
 :phase :enter,
 :input "artesan",
 :output :artesan}

{:schema int?
 :name :json
 :phase :enter
 :input 33100
 :output 33100}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant