LCOV - code coverage report
Current view: top level - schemas/domain - draws.clj Coverage Total Hit
Test: lcov.info Lines: 84.2 % 38 32
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns schemas.domain.draws
       2              :   (:require
       3              :    [malli.core :as m]
       4              :    [malli.error :as me]))
       5              : 
       6              : 
       7            4 : (def DrawRecordSchema
       8           28 :   [:map {:swagger/title       "DrawRecord"
       9              :          :swagger/description "Complete draw 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 :    [:stage-id [:ref :types/UuidString]]
      16           20 :    [:order {:optional true}
      17           12 :     [:maybe :int]]
      18           20 :    [:type {:optional true}
      19           12 :     [:maybe :string]]
      20           20 :    [:name {:optional true}
      21           12 :     [:maybe :string]]
      22           20 :    [:ruleset-id {:optional true}
      23           20 :     [:maybe [:ref :types/UuidString]]]
      24           24 :    [:config {:optional true}
      25              :     :any]
      26           24 :    [:created-datetime {:optional true}
      27              :     :any]
      28           20 :    [:source [:ref :matchscore/source]]])
      29              : 
      30              : 
      31            4 : (defrecord
      32              :   DrawRecord
      33              :   [uuid public-id stage-id order type name ruleset-id config created-datetime source])
      34              : 
      35              : 
      36            4 : (defn make-draw-record
      37              :  "Creates a Draw record with validation.
      38              :    Note: This validation uses the default registry. Ensure schemas.registry/init-registry!
      39              :    has been called before using this function."
      40              :  {:malli/schema [:=> [:cat DrawRecordSchema] DrawRecordSchema]}
      41              :  [{:keys [uuid public-id stage-id order type name ruleset-id config created-datetime source]
      42              :    :as   draw-data}]
      43           20 :  (if (m/validate DrawRecordSchema draw-data)
      44            8 :    (map->DrawRecord
      45           48 :     {:uuid             uuid
      46            4 :      :public-id        public-id
      47            4 :      :stage-id         stage-id
      48            4 :      :order            order
      49            4 :      :type             type
      50            4 :      :name             name
      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 draw data"
      58            0 :      {:type   :internal-validation-error
      59            0 :       :schema DrawRecordSchema
      60            0 :       :data   draw-data
      61            0 :       :humanized-errors (me/humanize (m/explain DrawRecordSchema draw-data))}))))
        

Generated by: LCOV version 2.0-1