Skip to content

Commit b599fa0

Browse files
committed
clean up specs, improve ::path spec
1 parent 9246967 commit b599fa0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/stencil/spec.clj

+13-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
relations/rel-type-main
1919
relations/rel-type-slide})
2020

21-
(s/def :stencil.model/path (s/and string? not-empty #(not (.startsWith ^String % "/"))))
21+
(s/def :stencil.model/path (s/and string?
22+
not-empty
23+
#(not (.startsWith (str %) "/"))
24+
#(not (.endsWith (str %) "/"))
25+
#(not (.contains (str %) ".."))))
2226

2327
;; relationship file
2428
(s/def ::relations (s/keys :req [:stencil.model/path]
@@ -32,13 +36,12 @@
3236
(s/def ::style (s/keys :req [:stencil.model/path]
3337
:opt-un [::result]))
3438

35-
(s/def :stencil.model/headers+footers (s/* (s/keys :req [:stencil.model/path]
36-
:req-un [::source-file :stencil.model/executable :?/relations]
37-
:opt-un [::result])))
39+
(s/def :stencil.model/headers+footers
40+
(s/* (s/keys :req [:stencil.model/path]
41+
:req-un [::source-file :stencil.model/executable :?/relations]
42+
:opt-un [::result])))
3843

39-
(s/def ::source-folder (s/and (partial instance? java.io.File)
40-
fs/directory?
41-
fs/exists?))
44+
(s/def ::source-folder (s/and fs/directory? fs/exists?))
4245

4346
(s/def ::source-file (s/and (partial instance? java.io.File)
4447
(complement fs/directory?)
@@ -63,8 +66,9 @@
6366

6467
(s/def ::parsed any?)
6568

66-
(s/def :stencil.model/numbering (s/nilable (s/keys :req [:stencil.model/path]
67-
:req-un [::source-file ::parsed])))
69+
(s/def :stencil.model/numbering
70+
(s/nilable (s/keys :req [:stencil.model/path]
71+
:req-un [::source-file ::parsed])))
6872

6973
(s/fdef stencil.model/load-template-model
7074
:args (s/cat :dir ::source-folder, :opts map?)

0 commit comments

Comments
 (0)