Skip to content

Commit 6e06f85

Browse files
committed
properly handle missing ids
1 parent 4164f95 commit 6e06f85

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/xapi_schema/spec.cljc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,11 +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
1379-
(empty? statements)
1380-
(reduce distinct?
1381-
(map #(get % "id") statements))
1382-
::s/invalid))
1378+
(let [ids (keep #(get % "id") statements)]
1379+
(or
1380+
(empty? ids)
1381+
(reduce distinct? ids)
1382+
::s/invalid)))
13831383

13841384
(s/def ::statements
13851385
(s/and

0 commit comments

Comments
 (0)