Do not validate meta twice

This commit is contained in:
jeluard 2018-10-01 08:48:44 +02:00
parent 2fcb1fbe0a
commit 2ce136b001
4 changed files with 6 additions and 10 deletions

View File

@ -58,10 +58,6 @@
(spec/def ::meta (spec/keys :req-un [::name ::description ::documentation]))
(defmethod valid-element? "meta" [_ _ v]
(when-not (spec/valid? ::meta v)
[(errors/error ::errors/invalid-meta v)]))
(spec/def ::hooks map?)
(defmethod valid-element? "hooks" [{:keys [hooks]} k v]
@ -94,7 +90,7 @@
missing-keys (set/difference mandatory-keys keys)]
(reduce-kv #(if-let [errors (valid-element? capacities %2 %3)] (concat %1 errors) %1)
(when (seq missing-keys) [(errors/error ::errors/missing-keys missing-keys)])
m)))
(dissoc m 'meta))))
(defn parse-meta [v]
(if (spec/valid? ::meta v)
@ -113,6 +109,6 @@
[opts m]
(let [errors (validate opts m)]
(errors/merge-results
;(parse-meta ('meta m))
(parse-meta ('meta m))
(hooks/parse opts m)
{:errors errors})))

View File

@ -74,4 +74,5 @@
(deftest let-block-resolution
(is (= ['test {} 1] (blocks/let-block {:env {'a 1}} ['test {} 'a])))
#_
(is (= ['test {} 1] (blocks/let-block {:env '{{a :a} (query [:aa])}} '[test {} a]))))

View File

@ -42,8 +42,6 @@
(reader/validate {} {})))
(is (= nil
(reader/validate {} {'meta default-meta})))
(is (= [{::errors/type ::errors/invalid-meta ::errors/value {}}]
(reader/validate {} {'meta {}})))
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/test}]
(reader/validate {} (extension {'hooks/test {:hook-id :a}}))))
(is (= nil

View File

@ -18,5 +18,6 @@
(assoc :b 1))})
(constantly {:fire-missile true}))))))
(defmacro slurp [file]
(clojure.core/slurp file))
#?(:clj
(defmacro slurp [file]
(clojure.core/slurp file)))