Refactor type matching

This commit is contained in:
bom 2023-07-06 15:00:40 +02:00
parent a324de35e4
commit 9e46120bf1

View file

@ -19,19 +19,23 @@
; Link Types
"Mention"})
(defn match-type
[type]
#(= (:type %) type))
(s/def ::Object (s/or
:uri core/uri-string?
:map (s/and (s/keys
:req-un [::id ::type]
:opt-un [::attributedTo ::und-mehr])
#(not (= (:type %) "Link")))))
#(not (match-type "Link")))))
(s/def ::id core/uri-string?)
(s/def ::type #(or (core/uri-string? %) (contains? objectAndLinkTypes %)))
(s/def ::Link (s/and (s/keys
:req-un [::type]
:opt-un [::attributedTo ::und-mehr])
#(= (:type %) "Link")))
(match-type "Link")))
(s/def ::Relationship (s/keys :req-un [::object ::und-mehr]))
@ -51,7 +55,6 @@
(s/def ::attributedTo ::Property)
(s/def ::actor ::attributedTo)
(s/def ::object
::Property)
@ -69,11 +72,9 @@
(s/def ::verb core/uri-string?)
; #### LIKE ####
(s/def ::Like ::Activity)
(s/def ::Like (s/and ::Activity
(match-type "Like")))
; Was beim Type Activity optional und required ist, ist abhängig vom Aktivitätstyp.
; Bspw brauch ein Like einen actor und den type "Like" und (xor) target/object.