From df87ec2c066cb06e3de72296333ac3851702a258 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 14 Aug 2023 09:43:54 +0200 Subject: [PATCH] Make uuid transformer to be case insensitive --- src/malli/transform.cljc | 2 +- test/malli/transform_test.cljc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/malli/transform.cljc b/src/malli/transform.cljc index e7e4a1e63..fae3a06f0 100644 --- a/src/malli/transform.cljc +++ b/src/malli/transform.cljc @@ -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) diff --git a/test/malli/transform_test.cljc b/test/malli/transform_test.cljc index 15b2e5936..eeffb58de 100644 --- a/test/malli/transform_test.cljc +++ b/test/malli/transform_test.cljc @@ -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