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

Add a note to the README about humanizing exceptions #901

Merged
Merged
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ Explain results can be humanized with `malli.error/humanize`:
; :lonlat [nil ["should be a double"]]}}
```

Or if you already have a malli validation exception (e.g. in a catch form):

```clojure
(require '[malli.error :as me])

(try
(m/validate Address {:not "an address"})
(catch Exception e
(-> e ex-data :data :explain me/humanize)))
```

## Custom error messages

Error messages can be customized with `:error/message` and `:error/fn` properties:
Expand Down