Skip to content

Commit

Permalink
Merge pull request #929 from niwinz/icase-uuid
Browse files Browse the repository at this point in the history
Make uuid transformer to be case insensitive
  • Loading branch information
ikitommi authored Aug 14, 2023
2 parents fee1f17 + df87ec2 commit 620666f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/malli/transform.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
x))

(def ^:private uuid-re
#"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$")
#"(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$")

(defn -string->uuid [x]
(if (string? x)
Expand Down
2 changes: 2 additions & 0 deletions test/malli/transform_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
(deftest string->uuid
(is (= #uuid "5f60751d-9bf7-4344-97ee-48643c9949ce" (mt/-string->uuid "5f60751d-9bf7-4344-97ee-48643c9949ce")))
(is (= #uuid "5f60751d-9bf7-4344-97ee-48643c9949ce" (mt/-string->uuid #uuid "5f60751d-9bf7-4344-97ee-48643c9949ce")))
(is (= #uuid "b3c4e6b4-6304-4a52-99c3-cb50e737bb94" (mt/-string->uuid "B3C4E6B4-6304-4A52-99C3-CB50E737BB94")))

(is (= "abba" (mt/-string->uuid "abba")))

;; Regression tests: we should ensure that invalid or incomplete
Expand Down

0 comments on commit 620666f

Please sign in to comment.