Skip to content

Commit

Permalink
Add a tip for #508
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Aug 19, 2021
1 parent 9dbc255 commit 55337ba
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,23 @@ In action:
[:user/id :string]]]])
; =throws=> :user/ambiguous-references {:data {:string #{[:child :user/id]}, :int #{[:user/id]}}}
```

## Getting error-values into humanized result

```clj
(-> [:map
[:x :int]
[:y [:set :keyword]]
[:z [:map
[:a [:tuple :int :int]]]]]
(m/explain {:x "1"
:y #{:a "b" :c}
:z {:a [1 "2"]}})
(me/humanize {:wrap #(select-keys % [:value :message])}))
;{:x [{:value "1"
; :message "should be an integer"}],
; :y #{[{:value "b"
; :message "should be a keyword"}]},
; :z {:a [nil [{:value "2"
; :message "should be an integer"}]]}}
```

0 comments on commit 55337ba

Please sign in to comment.