LCOV - code coverage report
Current view: top level - schemas/domain - groups.clj Coverage Total Hit
Test: lcov.info Lines: 82.9 % 35 29
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns schemas.domain.groups
       2              :   (:require
       3              :    [malli.core :as m]
       4              :    [malli.error :as me]))
       5              : 
       6              : 
       7            4 : (def GroupRecordSchema
       8           28 :   [:map {:swagger/title       "GroupRecord"
       9              :          :swagger/description "Complete group record from database"}
      10           20 :    [:uuid [:ref :types/UuidString]]
      11            8 :    [:public-id
      12           36 :     [:string {:min         1
      13              :               :description "Public-facing nanoid identifier"
      14              :               :example     "V1StGXR8_Z5j"}]]
      15           20 :    [:draw-id [:ref :types/UuidString]]
      16            8 :    [:name
      17           44 :     [:string {:min         1
      18              :               :max         255
      19              :               :description "Group name"
      20              :               :example     "Group A"}]]
      21           20 :    [:order {:optional true}
      22           12 :     [:maybe :int]]
      23           20 :    [:ruleset-id {:optional true}
      24           20 :     [:maybe [:ref :types/UuidString]]]
      25           24 :    [:config {:optional true}
      26              :     :any]
      27           24 :    [:created-datetime {:optional true}
      28              :     :any]
      29           20 :    [:source [:ref :matchscore/source]]])
      30              : 
      31              : 
      32            4 : (defrecord
      33              :   GroupRecord
      34              :   [uuid public-id draw-id name order ruleset-id config created-datetime source])
      35              : 
      36              : 
      37            4 : (defn make-group-record
      38              :  "Creates a Group record with validation.
      39              :    Note: This validation uses the default registry. Ensure schemas.registry/init-registry!
      40              :    has been called before using this function."
      41              :  {:malli/schema [:=> [:cat GroupRecordSchema] GroupRecordSchema]}
      42              :  [{:keys [uuid public-id draw-id name order ruleset-id config created-datetime source]
      43              :    :as   group-data}]
      44           20 :  (if (m/validate GroupRecordSchema group-data)
      45            8 :    (map->GroupRecord
      46           44 :     {:uuid             uuid
      47            4 :      :public-id        public-id
      48            4 :      :draw-id          draw-id
      49            4 :      :name             name
      50            4 :      :order            order
      51            4 :      :ruleset-id       ruleset-id
      52            4 :      :config           config
      53            4 :      :created-datetime created-datetime
      54            4 :      :source           source})
      55            0 :    (throw
      56            0 :     (ex-info
      57              :      "Invalid group data"
      58            0 :      {:type   :internal-validation-error
      59            0 :       :schema GroupRecordSchema
      60            0 :       :data   group-data
      61            0 :       :humanized-errors (me/humanize (m/explain GroupRecordSchema group-data))}))))
        

Generated by: LCOV version 2.0-1