文件名称:Clojure(Script)库ClojureSchema.zip
文件大小:81KB
文件格式:ZIP
更新时间:2022-08-06 05:08:50
开源项目
Schema 是一个 Clojure(Script) 库,用来声明数据描述和验证。 代码示例:(ns schema-examples (:require [schema.core :as s :include-macros true ;; cljs only ])) (def Data "A schema for a nested data type" {:a {:b s/Str :c s/Int} :d [{:e s/Keyword :f [s/Num]}]}) (s/validate Data {:a {:b "abc" :c 123} :d [{:e :bc :f [12.2 13 100]} {:e :bc :f [-1]}]}) ;; Success! (s/validate Data {:a {:b 123 :c "ABC"}}) ;; Exception -- Value does not match schema: ;; {:a {:b (not (instance? java.lang.String 123)), ;; :c (not (integer? "ABC"))}, ;; :d missing-required-key} 标签:Clojure
【文件预览】:
schema-master
----bin()
--------release.sh(129B)
--------setup_codox.sh(320B)
--------push_docs.sh(450B)
----project.clj(4KB)
----.github()
--------ISSUE_TEMPLATE.md(266B)
----test()
--------cljx()
--------clj()
--------cljs()
----CONTRIBUTING.md(2KB)
----src()
--------cljx()
--------clj()
----LICENSE.md(31KB)
----.gitignore(64B)
----CHANGELOG.md(10KB)
----.circleci()
--------config.yml(939B)
----README.md(19KB)