Implement and use uri-string?
This commit is contained in:
parent
e4aec1b256
commit
01d4799fb2
2 changed files with 9 additions and 5 deletions
|
@ -1,13 +1,14 @@
|
||||||
(ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2
|
(ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2
|
||||||
(:require [clojure.spec.alpha :as s]))
|
(:require [clojure.spec.alpha :as s]
|
||||||
|
[org.domaindrivenarchitecture.activity-pub-poc.core :as core]))
|
||||||
|
|
||||||
(s/def ::Object (s/or
|
(s/def ::Object (s/or
|
||||||
:uri any? ; TODO: This should only check for uri
|
:uri core/uri-string?
|
||||||
:map (s/keys
|
:map (s/keys
|
||||||
:req-un [::id ::type] ;type darf nicht "Link" sein
|
:req-un [::id ::type] ;type darf nicht "Link" sein
|
||||||
:opt-un [::attributedTo ::und-mehr])))
|
:opt-un [::attributedTo ::und-mehr])))
|
||||||
(s/def ::id any?) ; TODO: This should only check for uri
|
(s/def ::id core/uri-string?)
|
||||||
(s/def ::type any?);(fn [s] (s/or (uri? s) (= s "Link"))))
|
(s/def ::type #(or (core/uri-string? %) (= % "Link")))
|
||||||
|
|
||||||
(s/def ::Link (s/keys
|
(s/def ::Link (s/keys
|
||||||
:req-un [::type] ; type muss "Link" sein
|
:req-un [::type] ; type muss "Link" sein
|
||||||
|
|
|
@ -29,9 +29,12 @@
|
||||||
(defn type-string? [input]
|
(defn type-string? [input]
|
||||||
(re-matches #"[A-Z]" (str (first input))))
|
(re-matches #"[A-Z]" (str (first input))))
|
||||||
|
|
||||||
(defn uri-string? [input]
|
(defn url-string? [input]
|
||||||
(re-matches #"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" input))
|
(re-matches #"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" input))
|
||||||
|
|
||||||
|
(defn uri-string? [input]
|
||||||
|
(re-matches #"\w+:(\/?\/?)[^\s]+" input))
|
||||||
|
|
||||||
(defn uri-vector? [input]
|
(defn uri-vector? [input]
|
||||||
(and (every? #(uri-string? %) input)
|
(and (every? #(uri-string? %) input)
|
||||||
(vector? input)))
|
(vector? input)))
|
||||||
|
|
Loading…
Reference in a new issue