From 3dd9ff8ed00e41f48412fac5fee88f38281cd8b5 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Wed, 2 Aug 2023 08:46:28 +0200 Subject: [PATCH] implement type --- .../activity_pub_poc/activitystreams2.cljc | 4 +++- .../activity_pub_poc/activitystreams2_test.cljc | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 251f301..cd86a21 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -88,7 +88,9 @@ ;https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type ;TODO: this can not be found in the ttl / namespace. Where is this exactly defined? (s/def ::type - ::xsd/anyURI) + (s/or + :single-value ::xsd/anyURI + :coll-of-values (s/+ ::xsd/anyURI))) ;http://www.w3.org/ns/activitystreams#result (s/def ::result diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc index a69ee36..8414306 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc @@ -12,6 +12,18 @@ (is (not (s/valid? ::sut/id "https://no-uri:abc"))) (is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"])))) + +(deftest type-test + (is (s/valid? ::sut/type "https://social.bla/alyssa/status/RANDOMHASH")) + (is (s/valid? ::sut/type "Activity")) + (is (s/valid? ::sut/type "Activity")) + (is (s/valid? ::sut/type ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"])) + (is (not (s/valid? ::sut/type nil))) + (is (not (s/valid? ::sut/type []))) + (is (not (s/valid? ::sut/type 2))) + (is (not (s/valid? ::sut/type "https://no-uri:abc"))) + ) + (deftest object-test (is (s/valid? ::sut/object "http://example.org/posts/1")) (is (s/valid? ::sut/object {:type "Note",