Skip to content

Commit 184fbf3

Browse files
committed
ensure unique ids
1 parent c5559ea commit 184fbf3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/xapi_schema/spec.cljc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,8 +1372,16 @@
13721372
(some-> s :statement/object :statement-ref/objectType)
13731373
true)))))
13741374

1375+
(defn unique-statement-ids?
1376+
"Spec predicate to ensure that the IDs of a list of statements are unique."
1377+
[statements]
1378+
(or (distinct? (map #(get % "id") statements))
1379+
::s/invalid))
1380+
13751381
(s/def ::statements
1376-
(s/coll-of ::statement :into []))
1382+
(s/and
1383+
(s/coll-of ::statement :into [])
1384+
unique-statement-ids?))
13771385

13781386
(s/def ::lrs-statements
13791387
(s/coll-of ::lrs-statement :into []))

0 commit comments

Comments
 (0)