🔥 Remove core.spec usage on common and frontend

This commit is contained in:
Andrey Antukh
2025-11-26 15:06:53 +01:00
parent d34b6b88b6
commit 964ef799c2
12 changed files with 92 additions and 106 deletions

View File

@@ -14,8 +14,7 @@
[app.common.schema :as sm] [app.common.schema :as sm]
[clojure.core :as c] [clojure.core :as c]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[cuerdas.core :as str] [cuerdas.core :as str])
[expound.alpha :as expound])
#?(:clj #?(:clj
(:import (:import
clojure.lang.IPersistentMap))) clojure.lang.IPersistentMap)))
@@ -110,13 +109,6 @@
(contains? data :explain)) (contains? data :explain))
(explain (:explain data) opts) (explain (:explain data) opts)
(and (contains? data ::s/problems)
(contains? data ::s/value)
(contains? data ::s/spec))
(binding [s/*explain-out* expound/printer]
(with-out-str
(s/explain-out (update data ::s/problems #(take (:length opts 10) %)))))
(contains? data ::sm/explain) (contains? data ::sm/explain)
(sm/humanize-explain (::sm/explain data) opts))) (sm/humanize-explain (::sm/explain data) opts)))

View File

@@ -18,7 +18,6 @@
[app.common.logic.shapes :as cls] [app.common.logic.shapes :as cls]
[app.common.logic.variant-properties :as clvp] [app.common.logic.variant-properties :as clvp]
[app.common.path-names :as cpn] [app.common.path-names :as cpn]
[app.common.spec :as us]
[app.common.types.component :as ctk] [app.common.types.component :as ctk]
[app.common.types.components-list :as ctkl] [app.common.types.components-list :as ctkl]
[app.common.types.container :as ctn] [app.common.types.container :as ctn]
@@ -35,8 +34,7 @@
[app.common.types.typography :as cty] [app.common.types.typography :as cty]
[app.common.types.variant :as ctv] [app.common.types.variant :as ctv]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[clojure.set :as set] [clojure.set :as set]))
[clojure.spec.alpha :as s]))
;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default ;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default
(log/set-level! :warn) (log/set-level! :warn)
@@ -473,10 +471,10 @@
If an asset id is given, only shapes linked to this particular asset will If an asset id is given, only shapes linked to this particular asset will
be synchronized." be synchronized."
[changes file-id asset-type asset-id library-id libraries current-file-id] [changes file-id asset-type asset-id library-id libraries current-file-id]
(s/assert #{:colors :components :typographies} asset-type) (assert (contains? #{:colors :components :typographies} asset-type))
(s/assert (s/nilable ::us/uuid) asset-id) (assert (or (nil? asset-id) (uuid? asset-id)))
(s/assert ::us/uuid file-id) (assert (uuid? file-id))
(s/assert ::us/uuid library-id) (assert (uuid? library-id))
(container-log :info asset-id (container-log :info asset-id
:msg "Sync file with library" :msg "Sync file with library"
@@ -510,10 +508,10 @@
If an asset id is given, only shapes linked to this particular asset will If an asset id is given, only shapes linked to this particular asset will
be synchronized." be synchronized."
[changes file-id asset-type asset-id library-id libraries current-file-id] [changes file-id asset-type asset-id library-id libraries current-file-id]
(s/assert #{:colors :components :typographies} asset-type) (assert (contains? #{:colors :components :typographies} asset-type))
(s/assert (s/nilable ::us/uuid) asset-id) (assert (or (nil? asset-id) (uuid? asset-id)))
(s/assert ::us/uuid file-id) (assert (uuid? file-id))
(s/assert ::us/uuid library-id) (assert (uuid? library-id))
(container-log :info asset-id (container-log :info asset-id
:msg "Sync local components with library" :msg "Sync local components with library"

View File

@@ -1003,6 +1003,9 @@
(def valid-safe-number? (def valid-safe-number?
(lazy-validator ::safe-number)) (lazy-validator ::safe-number))
(def valid-safe-int?
(lazy-validator ::safe-int))
(def valid-text? (def valid-text?
(validator ::text)) (validator ::text))

View File

@@ -8,7 +8,6 @@
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.schema :as sm] [app.common.schema :as sm]
[app.common.spec :as us]
[app.common.types.profile :refer [schema:profile]] [app.common.types.profile :refer [schema:profile]]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cf] [app.config :as cf]
@@ -484,7 +483,7 @@
(defn delete-access-token (defn delete-access-token
[{:keys [id] :as params}] [{:keys [id] :as params}]
(us/assert! ::us/uuid id) (assert (uuid? id))
(ptk/reify ::delete-access-token (ptk/reify ::delete-access-token
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]

View File

@@ -11,7 +11,6 @@
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
[app.common.path-names :as cpn] [app.common.path-names :as cpn]
[app.common.spec :as us]
[app.common.thumbnails :as thc] [app.common.thumbnails :as thc]
[app.common.types.component :as ctk] [app.common.types.component :as ctk]
[app.common.types.container :as ctn] [app.common.types.container :as ctn]
@@ -38,7 +37,6 @@
[app.util.i18n :as i18n :refer [c tr]] [app.util.i18n :as i18n :refer [c tr]]
[app.util.strings :refer [matches-search]] [app.util.strings :refer [matches-search]]
[app.util.timers :as ts] [app.util.timers :as ts]
[cljs.spec.alpha :as s]
[cuerdas.core :as str] [cuerdas.core :as str]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
@@ -97,10 +95,6 @@
(str (str/slice (:path asset) (count path))) (str (str/slice (:path asset) (count path)))
(cpn/merge-path-item (:name asset)))) (cpn/merge-path-item (:name asset))))
(s/def ::asset-name ::us/not-empty-string)
(s/def ::name-group-form
(s/keys :req-un [::asset-name]))
(def initial-context-menu-state (def initial-context-menu-state
{:open? false :top nil :left nil}) {:open? false :top nil :left nil})

View File

@@ -7,7 +7,7 @@
(ns app.plugins.comments (ns app.plugins.comments
(:require (:require
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.spec :as us] [app.common.schema :as sm]
[app.main.data.comments :as dc] [app.main.data.comments :as dc]
[app.main.data.helpers :as dsh] [app.main.data.helpers :as dsh]
[app.main.data.workspace.comments :as dwc] [app.main.data.workspace.comments :as dwc]
@@ -118,7 +118,8 @@
(fn [position] (fn [position]
(let [position (parser/parse-point position)] (let [position (parser/parse-point position)]
(cond (cond
(or (not (us/safe-number? (:x position))) (not (us/safe-number? (:y position)))) (or (not (sm/valid-safe-number? (:x position)))
(not (sm/valid-safe-number? (:y position))))
(u/display-not-valid :position "Not valid point") (u/display-not-valid :position "Not valid point")
(not (r/check-permission plugin-id "comment:write")) (not (r/check-permission plugin-id "comment:write"))

View File

@@ -7,7 +7,7 @@
(ns app.plugins.flex (ns app.plugins.flex
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.spec :as us] [app.common.schema :as sm]
[app.common.types.shape.layout :as ctl] [app.common.types.shape.layout :as ctl]
[app.main.data.workspace.shape-layout :as dwsl] [app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.transforms :as dwt] [app.main.data.workspace.transforms :as dwt]
@@ -133,7 +133,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :rowGap value) (u/display-not-valid :rowGap value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -148,7 +148,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :columnGap value) (u/display-not-valid :columnGap value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -163,7 +163,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :verticalPadding value) (u/display-not-valid :verticalPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -178,7 +178,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :horizontalPadding value) (u/display-not-valid :horizontalPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -194,7 +194,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :topPadding value) (u/display-not-valid :topPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -209,7 +209,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :rightPadding value) (u/display-not-valid :rightPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -224,7 +224,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :bottomPadding value) (u/display-not-valid :bottomPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -239,7 +239,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :leftPadding value) (u/display-not-valid :leftPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -296,7 +296,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(us/safe-int? value) (sm/valid-safe-int? value)
(u/display-not-valid :zIndex value) (u/display-not-valid :zIndex value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -359,7 +359,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :verticalMargin value) (u/display-not-valid :verticalMargin value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -374,7 +374,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :horizontalMargin value) (u/display-not-valid :horizontalMargin value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -389,7 +389,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :topMargin value) (u/display-not-valid :topMargin value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -404,7 +404,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :rightMargin value) (u/display-not-valid :rightMargin value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -419,7 +419,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :bottomMargin value) (u/display-not-valid :bottomMargin value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -434,7 +434,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :leftMargin value) (u/display-not-valid :leftMargin value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -449,7 +449,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :maxWidth value) (u/display-not-valid :maxWidth value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -464,7 +464,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :minWidth value) (u/display-not-valid :minWidth value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -479,7 +479,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :maxHeight value) (u/display-not-valid :maxHeight value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -494,7 +494,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :minHeight value) (u/display-not-valid :minHeight value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))

View File

@@ -7,7 +7,7 @@
(ns app.plugins.grid (ns app.plugins.grid
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.spec :as us] [app.common.schema :as sm]
[app.common.types.shape.layout :as ctl] [app.common.types.shape.layout :as ctl]
[app.main.data.workspace.shape-layout :as dwsl] [app.main.data.workspace.shape-layout :as dwsl]
[app.main.data.workspace.transforms :as dwt] [app.main.data.workspace.transforms :as dwt]
@@ -126,7 +126,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :rowGap value) (u/display-not-valid :rowGap value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -141,7 +141,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :columnGap value) (u/display-not-valid :columnGap value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -156,7 +156,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :verticalPadding value) (u/display-not-valid :verticalPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -171,7 +171,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :horizontalPadding value) (u/display-not-valid :horizontalPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -186,7 +186,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :topPadding value) (u/display-not-valid :topPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -201,7 +201,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :rightPadding value) (u/display-not-valid :rightPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -216,7 +216,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :bottomPadding value) (u/display-not-valid :bottomPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -231,7 +231,7 @@
:set :set
(fn [_ value] (fn [_ value]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :leftPadding value) (u/display-not-valid :leftPadding value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -248,7 +248,7 @@
(u/display-not-valid :addRow-type type) (u/display-not-valid :addRow-type type)
(and (or (= :percent type) (= :flex type) (= :fixed type)) (and (or (= :percent type) (= :flex type) (= :fixed type))
(not (us/safe-number? value))) (not (sm/valid-safe-number? value)))
(u/display-not-valid :addRow-value value) (u/display-not-valid :addRow-value value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -261,14 +261,14 @@
(fn [index type value] (fn [index type value]
(let [type (keyword type)] (let [type (keyword type)]
(cond (cond
(not (us/safe-int? index)) (not (sm/valid-safe-int? index))
(u/display-not-valid :addRowAtIndex-index index) (u/display-not-valid :addRowAtIndex-index index)
(not (contains? ctl/grid-track-types type)) (not (contains? ctl/grid-track-types type))
(u/display-not-valid :addRowAtIndex-type type) (u/display-not-valid :addRowAtIndex-type type)
(and (or (= :percent type) (= :flex type) (= :fixed type)) (and (or (= :percent type) (= :flex type) (= :fixed type))
(not (us/safe-number? value))) (not (sm/valid-safe-number? value)))
(u/display-not-valid :addRowAtIndex-value value) (u/display-not-valid :addRowAtIndex-value value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -285,7 +285,7 @@
(u/display-not-valid :addColumn-type type) (u/display-not-valid :addColumn-type type)
(and (or (= :percent type) (= :flex type) (= :lex type)) (and (or (= :percent type) (= :flex type) (= :lex type))
(not (us/safe-number? value))) (not (sm/valid-safe-number? value)))
(u/display-not-valid :addColumn-value value) (u/display-not-valid :addColumn-value value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -297,14 +297,14 @@
:addColumnAtIndex :addColumnAtIndex
(fn [index type value] (fn [index type value]
(cond (cond
(not (us/safe-int? index)) (not (sm/valid-safe-int? index))
(u/display-not-valid :addColumnAtIndex-index index) (u/display-not-valid :addColumnAtIndex-index index)
(not (contains? ctl/grid-track-types type)) (not (contains? ctl/grid-track-types type))
(u/display-not-valid :addColumnAtIndex-type type) (u/display-not-valid :addColumnAtIndex-type type)
(and (or (= :percent type) (= :flex type) (= :fixed type)) (and (or (= :percent type) (= :flex type) (= :fixed type))
(not (us/safe-number? value))) (not (sm/valid-safe-number? value)))
(u/display-not-valid :addColumnAtIndex-value value) (u/display-not-valid :addColumnAtIndex-value value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -317,7 +317,7 @@
:removeRow :removeRow
(fn [index] (fn [index]
(cond (cond
(not (us/safe-int? index)) (not (sm/valid-safe-int? index))
(u/display-not-valid :removeRow index) (u/display-not-valid :removeRow index)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -329,7 +329,7 @@
:removeColumn :removeColumn
(fn [index] (fn [index]
(cond (cond
(not (us/safe-int? index)) (not (sm/valid-safe-int? index))
(u/display-not-valid :removeColumn index) (u/display-not-valid :removeColumn index)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -342,14 +342,14 @@
(fn [index type value] (fn [index type value]
(let [type (keyword type)] (let [type (keyword type)]
(cond (cond
(not (us/safe-int? index)) (not (sm/valid-safe-int? index))
(u/display-not-valid :setColumn-index index) (u/display-not-valid :setColumn-index index)
(not (contains? ctl/grid-track-types type)) (not (contains? ctl/grid-track-types type))
(u/display-not-valid :setColumn-type type) (u/display-not-valid :setColumn-type type)
(and (or (= :percent type) (= :flex type) (= :fixed type)) (and (or (= :percent type) (= :flex type) (= :fixed type))
(not (us/safe-number? value))) (not (sm/valid-safe-number? value)))
(u/display-not-valid :setColumn-value value) (u/display-not-valid :setColumn-value value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -362,14 +362,14 @@
(fn [index type value] (fn [index type value]
(let [type (keyword type)] (let [type (keyword type)]
(cond (cond
(not (us/safe-int? index)) (not (sm/valid-safe-int? index))
(u/display-not-valid :setRow-index index) (u/display-not-valid :setRow-index index)
(not (contains? ctl/grid-track-types type)) (not (contains? ctl/grid-track-types type))
(u/display-not-valid :setRow-type type) (u/display-not-valid :setRow-type type)
(and (or (= :percent type) (= :flex type) (= :fixed type)) (and (or (= :percent type) (= :flex type) (= :fixed type))
(not (us/safe-number? value))) (not (sm/valid-safe-number? value)))
(u/display-not-valid :setRow-value value) (u/display-not-valid :setRow-value value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -393,10 +393,10 @@
(not (shape-proxy? child)) (not (shape-proxy? child))
(u/display-not-valid :appendChild-child child) (u/display-not-valid :appendChild-child child)
(or (< row 0) (not (us/safe-int? row))) (or (< row 0) (not (sm/valid-safe-int? row)))
(u/display-not-valid :appendChild-row row) (u/display-not-valid :appendChild-row row)
(or (< column 0) (not (us/safe-int? column))) (or (< column 0) (not (sm/valid-safe-int? column)))
(u/display-not-valid :appendChild-column column) (u/display-not-valid :appendChild-column column)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -431,7 +431,7 @@
(let [cell (locate-cell self) (let [cell (locate-cell self)
shape (u/proxy->shape self)] shape (u/proxy->shape self)]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :row-value value) (u/display-not-valid :row-value value)
(nil? cell) (nil? cell)
@@ -451,7 +451,7 @@
(let [shape (u/proxy->shape self) (let [shape (u/proxy->shape self)
cell (locate-cell self)] cell (locate-cell self)]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :rowSpan-value value) (u/display-not-valid :rowSpan-value value)
(nil? cell) (nil? cell)
@@ -471,7 +471,7 @@
(let [shape (u/proxy->shape self) (let [shape (u/proxy->shape self)
cell (locate-cell self)] cell (locate-cell self)]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :column-value value) (u/display-not-valid :column-value value)
(nil? cell) (nil? cell)
@@ -491,7 +491,7 @@
(let [shape (u/proxy->shape self) (let [shape (u/proxy->shape self)
cell (locate-cell self)] cell (locate-cell self)]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :columnSpan-value value) (u/display-not-valid :columnSpan-value value)
(nil? cell) (nil? cell)

View File

@@ -10,7 +10,7 @@
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.spec :as us] [app.common.schema :as sm]
[app.common.types.color :as cc] [app.common.types.color :as cc]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.comments :as dc] [app.main.data.comments :as dc]
@@ -299,7 +299,7 @@
(fn [orientation value board] (fn [orientation value board]
(let [shape (u/proxy->shape board)] (let [shape (u/proxy->shape board)]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :addRulerGuide "Value not a safe number") (u/display-not-valid :addRulerGuide "Value not a safe number")
(not (contains? #{"vertical" "horizontal"} orientation)) (not (contains? #{"vertical" "horizontal"} orientation))
@@ -345,8 +345,8 @@
(or (not (string? content)) (empty? content)) (or (not (string? content)) (empty? content))
(u/display-not-valid :addCommentThread "Content not valid") (u/display-not-valid :addCommentThread "Content not valid")
(or (not (us/safe-number? (:x position))) (or (not (sm/valid-safe-number? (:x position)))
(not (us/safe-number? (:y position)))) (not (sm/valid-safe-number? (:y position))))
(u/display-not-valid :addCommentThread "Position not valid") (u/display-not-valid :addCommentThread "Position not valid")
(and (some? board) (or (not (shape/shape-proxy? board)) (not (cfh/frame-shape? shape)))) (and (some? board) (or (not (shape/shape-proxy? board)) (not (cfh/frame-shape? shape))))

View File

@@ -8,7 +8,7 @@
(:require (:require
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
[app.common.spec :as us] [app.common.schema :as sm]
[app.main.data.workspace.guides :as dwgu] [app.main.data.workspace.guides :as dwgu]
[app.main.store :as st] [app.main.store :as st]
[app.plugins.format :as format] [app.plugins.format :as format]
@@ -77,7 +77,7 @@
:set :set
(fn [self value] (fn [self value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :position "Not valid position") (u/display-not-valid :position "Not valid position")
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))

View File

@@ -14,7 +14,6 @@
[app.common.path-names :as cpn] [app.common.path-names :as cpn]
[app.common.record :as crc] [app.common.record :as crc]
[app.common.schema :as sm] [app.common.schema :as sm]
[app.common.spec :as us]
[app.common.svg.path :as svg.path] [app.common.svg.path :as svg.path]
[app.common.types.color :as clr] [app.common.types.color :as clr]
[app.common.types.component :as ctk] [app.common.types.component :as ctk]
@@ -325,7 +324,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(or (not (us/safe-int? value)) (< value 0)) (or (not (sm/valid-safe-int? value)) (< value 0))
(u/display-not-valid :borderRadius value) (u/display-not-valid :borderRadius value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -341,7 +340,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :borderRadiusTopLeft value) (u/display-not-valid :borderRadiusTopLeft value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -357,7 +356,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :borderRadiusTopRight value) (u/display-not-valid :borderRadiusTopRight value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -373,7 +372,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :borderRadiusBottomRight value) (u/display-not-valid :borderRadiusBottomRight value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -389,7 +388,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(not (us/safe-int? value)) (not (sm/valid-safe-int? value))
(u/display-not-valid :borderRadiusBottomLeft value) (u/display-not-valid :borderRadiusBottomLeft value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -405,7 +404,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(or (not (us/safe-number? value)) (< value 0) (> value 1)) (or (not (sm/valid-safe-number? value)) (< value 0) (> value 1))
(u/display-not-valid :opacity value) (u/display-not-valid :opacity value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -492,7 +491,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :x value) (u/display-not-valid :x value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -510,7 +509,7 @@
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :y value) (u/display-not-valid :y value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -555,7 +554,7 @@
:set :set
(fn [self value] (fn [self value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :parentX value) (u/display-not-valid :parentX value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -582,7 +581,7 @@
:set :set
(fn [self value] (fn [self value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :parentY value) (u/display-not-valid :parentY value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -609,7 +608,7 @@
:set :set
(fn [self value] (fn [self value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :frameX value) (u/display-not-valid :frameX value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -636,7 +635,7 @@
:set :set
(fn [self value] (fn [self value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :frameY value) (u/display-not-valid :frameY value)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -795,10 +794,10 @@
:resize :resize
(fn [width height] (fn [width height]
(cond (cond
(or (not (us/safe-number? width)) (<= width 0)) (or (not (sm/valid-safe-number? width)) (<= width 0))
(u/display-not-valid :resize width) (u/display-not-valid :resize width)
(or (not (us/safe-number? height)) (<= height 0)) (or (not (sm/valid-safe-number? height)) (<= height 0))
(u/display-not-valid :resize height) (u/display-not-valid :resize height)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -1048,10 +1047,10 @@
(not (cfh/text-shape? shape)) (not (cfh/text-shape? shape))
(u/display-not-valid :getRange-shape "shape is not text") (u/display-not-valid :getRange-shape "shape is not text")
(or (not (us/safe-int? start)) (< start 0) (> start end)) (or (not (sm/valid-safe-int? start)) (< start 0) (> start end))
(u/display-not-valid :getRange-start start) (u/display-not-valid :getRange-start start)
(not (us/safe-int? end)) (not (sm/valid-safe-int? end))
(u/display-not-valid :getRange-end end) (u/display-not-valid :getRange-end end)
:else :else
@@ -1078,7 +1077,7 @@
:setParentIndex :setParentIndex
(fn [index] (fn [index]
(cond (cond
(not (us/safe-int? index)) (not (sm/valid-safe-int? index))
(u/display-not-valid :setParentIndex index) (u/display-not-valid :setParentIndex index)
(not (r/check-permission plugin-id "content:write")) (not (r/check-permission plugin-id "content:write"))
@@ -1230,7 +1229,7 @@
(fn [orientation value] (fn [orientation value]
(let [shape (u/locate-shape file-id page-id id)] (let [shape (u/locate-shape file-id page-id id)]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :addRulerGuide "Value not a safe number") (u/display-not-valid :addRulerGuide "Value not a safe number")
(not (contains? #{"vertical" "horizontal"} orientation)) (not (contains? #{"vertical" "horizontal"} orientation))

View File

@@ -7,7 +7,7 @@
(ns app.plugins.viewport (ns app.plugins.viewport
(:require (:require
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.spec :as us] [app.common.schema :as sm]
[app.main.data.workspace.viewport :as dwv] [app.main.data.workspace.viewport :as dwv]
[app.main.data.workspace.zoom :as dwz] [app.main.data.workspace.zoom :as dwz]
[app.main.store :as st] [app.main.store :as st]
@@ -37,10 +37,10 @@
(let [new-x (obj/get value "x") (let [new-x (obj/get value "x")
new-y (obj/get value "y")] new-y (obj/get value "y")]
(cond (cond
(not (us/safe-number? new-x)) (not (sm/valid-safe-number? new-x))
(u/display-not-valid :center-x new-x) (u/display-not-valid :center-x new-x)
(not (us/safe-number? new-y)) (not (sm/valid-safe-number? new-y))
(u/display-not-valid :center-y new-y) (u/display-not-valid :center-y new-y)
:else :else
@@ -62,7 +62,7 @@
:set :set
(fn [value] (fn [value]
(cond (cond
(not (us/safe-number? value)) (not (sm/valid-safe-number? value))
(u/display-not-valid :zoom value) (u/display-not-valid :zoom value)
:else :else