prismatic-schema

    1熱度

    1回答

    使用棱鏡/架構脅迫可以在強制失敗而不是錯誤消息時具有缺省值。 我有一個csv文件中的值可能是空的(零)或s/Int。在與下面的代碼的那一刻,我得到這樣的空白: #schema.utils.ErrorContainer{:error (not (integer? nil))} 代碼: (def answers (slurp "excel/answers.csv")) (def answers-

    9熱度

    1回答

    在開發過程中,我希望對所有使用schema.core/defn定義的函數啓用驗證,而不必使用:^:always-validate對其進行註釋。這個庫可以這樣嗎? 像這樣的東西不起作用,可能是因爲元數據只添加在編譯時: (def dev false) ;; example of schema validation (sm/defn ^{:always-validate dev} ad

    2熱度

    1回答

    我們對當前正在使用的Clojure 1.4的項目中使用評估Prismatic/schema。我們此時不希望在我們的項目中升級Clojure。 Schema需要Clojure 1.5.1,但repl中的一些基本測試並未顯示Clojure版本更改爲1.4時的任何問題。 有其他人使用Clojure的上1.4的模式嘗試,以及它如何走? 這裏就是我想(在project.clj改變的Clojure到1.4.0

    3熱度

    1回答

    我嘗試使用clojure的棱鏡/架構庫驗證映射。這裏是我的形狀 (require '[schema.core :as s]) (def d {"a" s/Str "b" s/Int}) 當我試圖驗證它針對的地圖,它拋出以下異常 (s/validate d {"a" "@@#$" "b" 2}) RuntimeException More than one non-optional/requ

    1熱度

    1回答

    我試圖使用棱柱型模式來強制地圖(1.0.4) 我試圖強迫 {:a 1} 到 {:b 1} 使用架構的自定義匹配器: {:b s/Int} 但這個代碼不工作: (require '[schema.core :as s]) (require '[schema.coerce :as coerce]) ((coerce/coercer {:b s/Int} (fn [s]

    3熱度

    1回答

    我想在一個前提條件使用Prismatic schema.core/maybe採取一個可選的參數opts的功能,但它似乎總是拋出AssertionError當我打電話,沒有opts功能: (require '[schema.core :as schema]) (defn foo [& modules] {:pre [(schema/validate (schema/maybe [(sc

    0熱度

    1回答

    的正則表達式似乎接受模式: (require '[schema.core :as schema]) (schema/validate #"^..$" "hi") ; => "hi" 但架構發電機似乎無法從他們身上產生: (require '[schema-generators.generators :as gen]) (gen/generate #"^..$") ; 1. Unhan

    0熱度

    2回答

    我想做一個謂詞函數,當匹配模式X時返回true,否則返回false。

    -2熱度

    1回答

    我在驗證clojure棱鏡模式時遇到問題。這是代碼。 :Some_Var1 {:Some_Var2 s/Str :Some_Var3 (s/conditional #(= "mytype1" (:type %)) s/Str #(= "mytype2" (:type %)) s/Str )} 我想使用的代碼來驗證它: "

    3熱度

    1回答

    我有一個關於使用Prismatic/schema驗證函數的非常簡單的問題。我有一個地圖有一個鍵的架構,它的值是一個函數,它接受一個Bar架構作爲其單個參數,返回任何東西(用於副作用): (require '[schema.core :as s]) (def Bar {:baz s/Int}) (def Action :???) (def Foo {:action Action}) 的問