mirror of https://github.com/status-im/pluto.git
Do not validate meta twice
This commit is contained in:
parent
2fcb1fbe0a
commit
2ce136b001
|
@ -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})))
|
||||
|
|
|
@ -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]))))
|
|
@ -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
|
||||
|
|
|
@ -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)))
|
||||
|
|
Loading…
Reference in New Issue