Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Malli is in well matured [alpha](README.md#alpha).
* previous behavior defaulted to a `nil`-returning generator, even if the schema doesn't accept `nil`
* use `:gen/return nil` property to restore this behavior
* FIX: `malli.registry/{mode,type}` not respected in Babashka [#1124](https://github.com/metosin/malli/issues/1124)
* FIX: `:float` missing humanizer [#1122](https://github.com/metosin/malli/issues/1122)
* Updated dependencies:

```
Expand Down
1 change: 1 addition & 0 deletions src/malli/error.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
max (str "should be at most " max " character" (when (not= 1 max) "s")))))}}
:int {:error/fn {:en (-pred-min-max-error-fn {:pred int?, :message "should be an integer"})}}
:double {:error/fn {:en (-pred-min-max-error-fn {:pred double?, :message "should be a double"})}}
:float {:error/fn {:en (-pred-min-max-error-fn {:pred float?, :message "should be a float"})}}
:boolean {:error/message {:en "should be a boolean"}}
:keyword {:error/message {:en "should be a keyword"}}
:symbol {:error/message {:en "should be a symbol"}}
Expand Down
45 changes: 23 additions & 22 deletions test/malli/error_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -372,28 +372,29 @@
(me/humanize)))))

(deftest double-test
(is (= {:a ["should be a double"]
:b ["should be at least 1"]
:c ["should be at most 4"]
:d [["should be at least 1"]
["should be at most 4"]]
:e ["should be a double"]
:f ["should be 4"]}
(-> [:map
[:a :double]
[:b [:double {:min 1}]]
[:c [:double {:max 4}]]
[:d [:vector [:double {:min 1, :max 4}]]]
[:e [:double {:min 1, :max 4}]]
[:f [:double {:min 4, :max 4}]]]
(m/explain
{:a "123"
:b 0.0
:c 5.0
:d [0.0 5.0]
:e "123"
:f 5.0})
(me/humanize)))))
(doseq [t [:double :float]]
(is (= {:a [(str "should be a " (name t))]
:b ["should be at least 1"]
:c ["should be at most 4"]
:d [["should be at least 1"]
["should be at most 4"]]
:e [(str "should be a " (name t))]
:f ["should be 4"]}
(-> [:map
[:a t]
[:b [t {:min 1}]]
[:c [t {:max 4}]]
[:d [:vector [t {:min 1, :max 4}]]]
[:e [t {:min 1, :max 4}]]
[:f [t {:min 4, :max 4}]]]
(m/explain
{:a "123"
:b 0.0
:c 5.0
:d [0.0 5.0]
:e "123"
:f 5.0})
(me/humanize))))))

(deftest any-test
(testing "success"
Expand Down
Loading