LCOV - code coverage report
Current view: top level - schemas - types.clj Coverage Total Hit
Test: lcov.info Lines: 73.3 % 30 22
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns schemas.types
       2              :   (:require
       3              :    [malli.core :as m]
       4              :    [malli.error :as me])
       5              :   (:import
       6              :    (java.util UUID)))
       7              : 
       8              : 
       9            4 : (defn uuid-string?
      10              :  [s]
      11            4 :  (try
      12           16 :    (let [uuid (UUID/fromString s)]
      13           20 :      (and
      14           24 :       (contains? #{4 7} (.version uuid))
      15            4 :       (re-matches
      16              :        #"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[47][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}"
      17            4 :        s)))
      18              :    (catch IllegalArgumentException _ false)))
      19              : 
      20              : 
      21            4 : (defn any-uuid-string?
      22              :  [s]
      23            0 :  (try
      24            0 :    (and
      25            0 :     (string? s)
      26            0 :     (UUID/fromString s)
      27            0 :     (re-matches #"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" s))
      28              :    (catch IllegalArgumentException _ false)))
      29              : 
      30              : 
      31            4 : (def UuidString
      32              :   "UUID string schema in raw vector form for use with the registry.
      33              :    Use with [:ref :UuidString] or validate directly."
      34           28 :   [:and {:swagger/title       "UuidString"
      35              :          :swagger/description "UUID string (v4 or v7)"}
      36           28 :    [:string {:description "UUID string (v4 or v7)"
      37              :              :example     "019577e0-1234-7abc-8000-abcdef012345"}]
      38           20 :    [:fn {:error/message "Must be a valid UUID string (v4 or v7)"}
      39            4 :     uuid-string?]])
      40              : 
      41              : 
      42            4 : (def AnyUuidString
      43              :   "UUID string schema for external IDs where the source may use older UUID versions."
      44           28 :   [:and {:swagger/title       "AnyUuidString"
      45              :          :swagger/description "UUID string"}
      46           28 :    [:string {:description "UUID string"
      47              :              :example     "443bf6b2-e894-11eb-9c4a-005056b7b0c0"}]
      48           20 :    [:fn {:error/message "Must be a valid UUID string"}
      49            4 :     any-uuid-string?]])
      50              : 
      51              : 
      52            4 : (def Source
      53              :   "Source system discriminator shared by imported and Matchscore-owned records."
      54           48 :   [:enum {:swagger/title       "Source"
      55              :           :swagger/description "Source system of a record"}
      56              :    "matchscore"
      57              :    "rankedin" "psa"
      58              :    "fsu"      "esf"])
      59              : 
      60              : 
      61            4 : (defn valid-uuid-string?
      62              :  [uuid-str]
      63            0 :  (if (m/validate UuidString uuid-str)
      64            0 :    [true nil]
      65            0 :    [false (me/humanize (m/explain UuidString uuid-str))]))
        

Generated by: LCOV version 2.0-1