-
Notifications
You must be signed in to change notification settings - Fork 4
/
axiom.cljc
46 lines (34 loc) · 1.05 KB
/
axiom.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(ns com.yetanalytics.flint.spec.axiom
(:require [clojure.spec.alpha :as s]
[com.yetanalytics.flint.axiom.protocol :as p]
[com.yetanalytics.flint.axiom.impl]))
;; Axiom specs
;; We need to wrap them in functions in order to ensure that the functions
;; are called dynamically, rather than have fixed definitions. Otherwise
;; `extend-protocol` will not work.
(def iri-spec
#(p/-valid-iri? %))
(def prefix-spec
#(p/-valid-prefix? %))
(def prefix-iri-spec
#(p/-valid-prefix-iri? %))
(def variable-spec
#(p/-valid-variable? %))
(def bnode-spec
#(p/-valid-bnode? %))
(def wildcard-spec
#(p/-valid-wildcard? %))
(def rdf-type-spec
#(p/-valid-rdf-type? %))
(def literal-spec
#(p/-valid-literal? %))
;; Composite specs
(def iri-or-prefixed-spec
"Spec for both prefixed and full IRIs."
(s/or :ax/iri iri-spec
:ax/prefix-iri prefix-iri-spec))
(def iri-or-var-spec
"Spec for both prefixed IRIs, full IRIs, and variables."
(s/or :ax/var variable-spec
:ax/iri iri-spec
:ax/prefix-iri prefix-iri-spec))