mirror of
https://github.com/status-im/re-frame.git
synced 2025-02-23 07:18:22 +00:00
add prismatic schema def WIP
This commit is contained in:
parent
ecead71638
commit
1eadd5ea0d
@ -3,7 +3,8 @@
|
|||||||
[org.clojure/clojurescript "0.0-2816"]
|
[org.clojure/clojurescript "0.0-2816"]
|
||||||
[reagent "0.5.0-alpha3"]
|
[reagent "0.5.0-alpha3"]
|
||||||
[figwheel "0.2.3-SNAPSHOT"]
|
[figwheel "0.2.3-SNAPSHOT"]
|
||||||
[re-frame "0.2.0"]]
|
[re-frame "0.2.0"]
|
||||||
|
[prismatic/schema "0.3.7"]]
|
||||||
|
|
||||||
:plugins [[lein-cljsbuild "1.0.4"]
|
:plugins [[lein-cljsbuild "1.0.4"]
|
||||||
[lein-figwheel "0.2.3-SNAPSHOT"]]
|
[lein-figwheel "0.2.3-SNAPSHOT"]]
|
||||||
|
@ -1,7 +1,24 @@
|
|||||||
(ns todomvc.db)
|
(ns todomvc.db
|
||||||
|
(:require
|
||||||
|
[schema.core :as s :include-macros true]))
|
||||||
|
|
||||||
|
|
||||||
(def default-initial-state
|
(def default-initial-state
|
||||||
{:todos (sorted-map) ;; todo ids are the keys (for sort)
|
{:todos (sorted-map) ;; todo ids are the keys (for sort)
|
||||||
:showing :all ;; one of :all :done or :active
|
:showing :all ;; one of :all :done or :active
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
(def schema
|
||||||
|
{:todos (s/both (s/pred map?) (s/pred sorted?))
|
||||||
|
:showing (s/enum :all :done :active)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
(defn valid-schema?
|
||||||
|
[db]
|
||||||
|
(s/validate schema db))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user