🚧 Use cljs.spec everywhere.

This commit is contained in:
Andrey Antukh 2019-09-09 23:21:55 +02:00
parent a009961a58
commit faf7877d00
15 changed files with 93 additions and 391 deletions

View file

@ -15,7 +15,7 @@
[uxbox.main.store :as st]
[uxbox.main.ui.messages :refer [messages-widget]]
[uxbox.util.dom :as dom]
[uxbox.util.forms2 :as fm2]
[uxbox.util.forms :as fm2]
[uxbox.util.i18n :refer [tr]]
[uxbox.util.router :as rt]))

View file

@ -7,7 +7,7 @@
(ns uxbox.main.ui.auth.recovery
(:require
[cljs.spec.alpha :as s :include-macros true]
[cljs.spec.alpha :as s]
[cuerdas.core :as str]
[lentes.core :as l]
[rumext.core :as mx :include-macros true]

View file

@ -7,10 +7,10 @@
(ns uxbox.main.ui.auth.register
(:require
[cljs.spec.alpha :as s]
[cuerdas.core :as str]
[lentes.core :as l]
[rumext.alpha :as mf]
[struct.alpha :as s]
[uxbox.builtins.icons :as i]
[uxbox.main.data.auth :as uda]
[uxbox.main.store :as st]
@ -21,11 +21,16 @@
[uxbox.util.i18n :refer [tr]]
[uxbox.util.router :as rt]))
(s/defs ::register-form
(s/dict :username (s/&& ::s/string ::fm/not-empty-string)
:fullname (s/&& ::s/string ::fm/not-empty-string)
:password (s/&& ::s/string ::fm/not-empty-string)
:email ::s/email))
(s/def ::username ::fm/not-empty-string)
(s/def ::fullname ::fm/not-empty-string)
(s/def ::password ::fm/not-empty-string)
(s/def ::email ::fm/email)
(s/def ::register-form
(s/keys :req-un [::username
::password
::fullname
::email]))
(defn- on-error
[error form]
@ -112,7 +117,6 @@
:type #{::api}
:field :email}]
[:input.btn-primary
{:type "submit"
:tab-index "5"

View file

@ -7,7 +7,7 @@
(ns uxbox.main.ui.dashboard.projects-forms
(:require
[struct.alpha :as s]
[cljs.spec.alpha :as s]
[rumext.alpha :as mf]
[uxbox.builtins.icons :as i]
[uxbox.main.data.projects :as udp]
@ -17,10 +17,12 @@
[uxbox.util.forms :as fm]
[uxbox.util.i18n :as t :refer [tr]]))
(s/defs ::project-form
(s/dict :name (s/&& ::s/string ::fm/not-empty-string)
:width ::s/number-str
:height ::s/number-str))
(s/def ::name ::fm/not-empty-string)
(s/def ::width ::fm/number-str)
(s/def ::height ::fm/number-str)
(s/def ::project-form
(s/keys :req-un [::name ::width ::height]))
(def defaults
{:name ""

View file

@ -13,7 +13,7 @@
[uxbox.main.data.users :as udu]
[uxbox.main.store :as st]
[uxbox.util.dom :as dom]
[uxbox.util.forms2 :as fm]
[uxbox.util.forms :as fm]
[uxbox.util.i18n :refer [tr]]
[uxbox.util.messages :as um]))

View file

@ -16,7 +16,7 @@
[uxbox.main.store :as st]
[uxbox.util.data :refer [read-string]]
[uxbox.util.dom :as dom]
[uxbox.util.forms2 :as fm]
[uxbox.util.forms :as fm]
[uxbox.util.i18n :as i18n :refer [tr]]
[uxbox.util.interop :refer [iterable->seq]]
[uxbox.util.messages :as um]))

View file

@ -8,22 +8,29 @@
(ns uxbox.main.ui.workspace.sidebar.sitemap-forms
(:require
[rumext.alpha :as mf]
[struct.alpha :as s]
[cljs.spec.alpha :as s]
[uxbox.builtins.icons :as i]
[uxbox.main.constants :as c]
[uxbox.main.data.pages :as udp]
[uxbox.main.store :as st]
[uxbox.main.ui.modal :as modal]
[uxbox.util.dom :as dom]
[uxbox.util.spec :as us]
[uxbox.util.forms :as fm]
[uxbox.util.i18n :refer [tr]]))
(s/defs ::page-form
(s/dict :id (s/opt ::s/uuid)
:project ::s/uuid
:name (s/&& ::s/string ::fm/not-empty-string)
:width ::s/number-str
:height ::s/number-str))
(s/def ::id ::us/uuid)
(s/def ::project ::us/uuid)
(s/def ::name ::us/not-empty-string)
(s/def ::width ::us/number-str)
(s/def ::height ::us/number-str)
(s/def ::page-form
(s/keys :req-un [::id
::project
::name
::width
::height]))
(def defaults
{:name ""