Skip to content

Commit

Permalink
Make uuid transformer to be case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Aug 14, 2023
1 parent fee1f17 commit df87ec2
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 df87ec2

Please sign in to comment.