Skip to content

Commit 4164f95

Browse files
committed
guard against empty list passed to distinct
1 parent 822e66b commit 4164f95

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/xapi_schema/spec.cljc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,17 +812,17 @@
812812
(-> scores
813813
(assoc :score/min raw)
814814
(assoc :score/raw min))
815-
815+
816816
(and min max (< max min))
817817
(-> scores
818818
(assoc :score/min max)
819819
(assoc :score/max min))
820-
820+
821821
(and raw max (< max raw))
822822
(-> scores
823823
(assoc :score/raw max)
824824
(assoc :score/max raw))
825-
825+
826826
:else
827827
scores))
828828

@@ -1375,8 +1375,11 @@
13751375
(defn unique-statement-ids?
13761376
"Spec predicate to ensure that the IDs of a list of statements are unique."
13771377
[statements]
1378-
(or (reduce distinct? (map #(get % "id") statements))
1379-
::s/invalid))
1378+
(or
1379+
(empty? statements)
1380+
(reduce distinct?
1381+
(map #(get % "id") statements))
1382+
::s/invalid))
13801383

13811384
(s/def ::statements
13821385
(s/and

0 commit comments

Comments
 (0)