diff --git a/common/src/app/common/exceptions.cljc b/common/src/app/common/exceptions.cljc index 4bb36461ea..6def4ef91c 100644 --- a/common/src/app/common/exceptions.cljc +++ b/common/src/app/common/exceptions.cljc @@ -14,8 +14,7 @@ [app.common.schema :as sm] [clojure.core :as c] [clojure.spec.alpha :as s] - [cuerdas.core :as str] - [expound.alpha :as expound]) + [cuerdas.core :as str]) #?(:clj (:import clojure.lang.IPersistentMap))) @@ -110,13 +109,6 @@ (contains? data :explain)) (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) (sm/humanize-explain (::sm/explain data) opts))) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index a2a8da1b9a..2844a6b1af 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -18,7 +18,6 @@ [app.common.logic.shapes :as cls] [app.common.logic.variant-properties :as clvp] [app.common.path-names :as cpn] - [app.common.spec :as us] [app.common.types.component :as ctk] [app.common.types.components-list :as ctkl] [app.common.types.container :as ctn] @@ -35,8 +34,7 @@ [app.common.types.typography :as cty] [app.common.types.variant :as ctv] [app.common.uuid :as uuid] - [clojure.set :as set] - [clojure.spec.alpha :as s])) + [clojure.set :as set])) ;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default (log/set-level! :warn) @@ -473,10 +471,10 @@ If an asset id is given, only shapes linked to this particular asset will be synchronized." [changes file-id asset-type asset-id library-id libraries current-file-id] - (s/assert #{:colors :components :typographies} asset-type) - (s/assert (s/nilable ::us/uuid) asset-id) - (s/assert ::us/uuid file-id) - (s/assert ::us/uuid library-id) + (assert (contains? #{:colors :components :typographies} asset-type)) + (assert (or (nil? asset-id) (uuid? asset-id))) + (assert (uuid? file-id)) + (assert (uuid? library-id)) (container-log :info asset-id :msg "Sync file with library" @@ -510,10 +508,10 @@ If an asset id is given, only shapes linked to this particular asset will be synchronized." [changes file-id asset-type asset-id library-id libraries current-file-id] - (s/assert #{:colors :components :typographies} asset-type) - (s/assert (s/nilable ::us/uuid) asset-id) - (s/assert ::us/uuid file-id) - (s/assert ::us/uuid library-id) + (assert (contains? #{:colors :components :typographies} asset-type)) + (assert (or (nil? asset-id) (uuid? asset-id))) + (assert (uuid? file-id)) + (assert (uuid? library-id)) (container-log :info asset-id :msg "Sync local components with library" diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index 6d40c9f16a..303b427c3e 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -1003,6 +1003,9 @@ (def valid-safe-number? (lazy-validator ::safe-number)) +(def valid-safe-int? + (lazy-validator ::safe-int)) + (def valid-text? (validator ::text)) diff --git a/frontend/src/app/main/data/profile.cljs b/frontend/src/app/main/data/profile.cljs index 1a77f6b9d3..127567f7b9 100644 --- a/frontend/src/app/main/data/profile.cljs +++ b/frontend/src/app/main/data/profile.cljs @@ -8,7 +8,6 @@ (:require [app.common.data :as d] [app.common.schema :as sm] - [app.common.spec :as us] [app.common.types.profile :refer [schema:profile]] [app.common.uuid :as uuid] [app.config :as cf] @@ -484,7 +483,7 @@ (defn delete-access-token [{:keys [id] :as params}] - (us/assert! ::us/uuid id) + (assert (uuid? id)) (ptk/reify ::delete-access-token ptk/WatchEvent (watch [_ _ _] diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs index 130da0bb82..9f7762b861 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs @@ -11,7 +11,6 @@ [app.common.data.macros :as dm] [app.common.files.helpers :as cfh] [app.common.path-names :as cpn] - [app.common.spec :as us] [app.common.thumbnails :as thc] [app.common.types.component :as ctk] [app.common.types.container :as ctn] @@ -38,7 +37,6 @@ [app.util.i18n :as i18n :refer [c tr]] [app.util.strings :refer [matches-search]] [app.util.timers :as ts] - [cljs.spec.alpha :as s] [cuerdas.core :as str] [rumext.v2 :as mf])) @@ -97,10 +95,6 @@ (str (str/slice (:path asset) (count path))) (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 {:open? false :top nil :left nil}) diff --git a/frontend/src/app/plugins/comments.cljs b/frontend/src/app/plugins/comments.cljs index b7c41530c8..f3cfdcf954 100644 --- a/frontend/src/app/plugins/comments.cljs +++ b/frontend/src/app/plugins/comments.cljs @@ -7,7 +7,7 @@ (ns app.plugins.comments (:require [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.helpers :as dsh] [app.main.data.workspace.comments :as dwc] @@ -118,7 +118,8 @@ (fn [position] (let [position (parser/parse-point position)] (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") (not (r/check-permission plugin-id "comment:write")) diff --git a/frontend/src/app/plugins/flex.cljs b/frontend/src/app/plugins/flex.cljs index a4119008c3..8f52299bd7 100644 --- a/frontend/src/app/plugins/flex.cljs +++ b/frontend/src/app/plugins/flex.cljs @@ -7,7 +7,7 @@ (ns app.plugins.flex (:require [app.common.data :as d] - [app.common.spec :as us] + [app.common.schema :as sm] [app.common.types.shape.layout :as ctl] [app.main.data.workspace.shape-layout :as dwsl] [app.main.data.workspace.transforms :as dwt] @@ -133,7 +133,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :rowGap value) (not (r/check-permission plugin-id "content:write")) @@ -148,7 +148,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :columnGap value) (not (r/check-permission plugin-id "content:write")) @@ -163,7 +163,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :verticalPadding value) (not (r/check-permission plugin-id "content:write")) @@ -178,7 +178,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :horizontalPadding value) (not (r/check-permission plugin-id "content:write")) @@ -194,7 +194,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :topPadding value) (not (r/check-permission plugin-id "content:write")) @@ -209,7 +209,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :rightPadding value) (not (r/check-permission plugin-id "content:write")) @@ -224,7 +224,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :bottomPadding value) (not (r/check-permission plugin-id "content:write")) @@ -239,7 +239,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :leftPadding value) (not (r/check-permission plugin-id "content:write")) @@ -296,7 +296,7 @@ :set (fn [_ value] (cond - (us/safe-int? value) + (sm/valid-safe-int? value) (u/display-not-valid :zIndex value) (not (r/check-permission plugin-id "content:write")) @@ -359,7 +359,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :verticalMargin value) (not (r/check-permission plugin-id "content:write")) @@ -374,7 +374,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :horizontalMargin value) (not (r/check-permission plugin-id "content:write")) @@ -389,7 +389,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :topMargin value) (not (r/check-permission plugin-id "content:write")) @@ -404,7 +404,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :rightMargin value) (not (r/check-permission plugin-id "content:write")) @@ -419,7 +419,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :bottomMargin value) (not (r/check-permission plugin-id "content:write")) @@ -434,7 +434,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :leftMargin value) (not (r/check-permission plugin-id "content:write")) @@ -449,7 +449,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :maxWidth value) (not (r/check-permission plugin-id "content:write")) @@ -464,7 +464,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :minWidth value) (not (r/check-permission plugin-id "content:write")) @@ -479,7 +479,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :maxHeight value) (not (r/check-permission plugin-id "content:write")) @@ -494,7 +494,7 @@ :set (fn [_ value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :minHeight value) (not (r/check-permission plugin-id "content:write")) diff --git a/frontend/src/app/plugins/grid.cljs b/frontend/src/app/plugins/grid.cljs index 7fedf00140..f57873ec31 100644 --- a/frontend/src/app/plugins/grid.cljs +++ b/frontend/src/app/plugins/grid.cljs @@ -7,7 +7,7 @@ (ns app.plugins.grid (:require [app.common.data :as d] - [app.common.spec :as us] + [app.common.schema :as sm] [app.common.types.shape.layout :as ctl] [app.main.data.workspace.shape-layout :as dwsl] [app.main.data.workspace.transforms :as dwt] @@ -126,7 +126,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :rowGap value) (not (r/check-permission plugin-id "content:write")) @@ -141,7 +141,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :columnGap value) (not (r/check-permission plugin-id "content:write")) @@ -156,7 +156,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :verticalPadding value) (not (r/check-permission plugin-id "content:write")) @@ -171,7 +171,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :horizontalPadding value) (not (r/check-permission plugin-id "content:write")) @@ -186,7 +186,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :topPadding value) (not (r/check-permission plugin-id "content:write")) @@ -201,7 +201,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :rightPadding value) (not (r/check-permission plugin-id "content:write")) @@ -216,7 +216,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :bottomPadding value) (not (r/check-permission plugin-id "content:write")) @@ -231,7 +231,7 @@ :set (fn [_ value] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :leftPadding value) (not (r/check-permission plugin-id "content:write")) @@ -248,7 +248,7 @@ (u/display-not-valid :addRow-type 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) (not (r/check-permission plugin-id "content:write")) @@ -261,14 +261,14 @@ (fn [index type value] (let [type (keyword type)] (cond - (not (us/safe-int? index)) + (not (sm/valid-safe-int? index)) (u/display-not-valid :addRowAtIndex-index index) (not (contains? ctl/grid-track-types type)) (u/display-not-valid :addRowAtIndex-type 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) (not (r/check-permission plugin-id "content:write")) @@ -285,7 +285,7 @@ (u/display-not-valid :addColumn-type 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) (not (r/check-permission plugin-id "content:write")) @@ -297,14 +297,14 @@ :addColumnAtIndex (fn [index type value] (cond - (not (us/safe-int? index)) + (not (sm/valid-safe-int? index)) (u/display-not-valid :addColumnAtIndex-index index) (not (contains? ctl/grid-track-types type)) (u/display-not-valid :addColumnAtIndex-type 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) (not (r/check-permission plugin-id "content:write")) @@ -317,7 +317,7 @@ :removeRow (fn [index] (cond - (not (us/safe-int? index)) + (not (sm/valid-safe-int? index)) (u/display-not-valid :removeRow index) (not (r/check-permission plugin-id "content:write")) @@ -329,7 +329,7 @@ :removeColumn (fn [index] (cond - (not (us/safe-int? index)) + (not (sm/valid-safe-int? index)) (u/display-not-valid :removeColumn index) (not (r/check-permission plugin-id "content:write")) @@ -342,14 +342,14 @@ (fn [index type value] (let [type (keyword type)] (cond - (not (us/safe-int? index)) + (not (sm/valid-safe-int? index)) (u/display-not-valid :setColumn-index index) (not (contains? ctl/grid-track-types type)) (u/display-not-valid :setColumn-type 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) (not (r/check-permission plugin-id "content:write")) @@ -362,14 +362,14 @@ (fn [index type value] (let [type (keyword type)] (cond - (not (us/safe-int? index)) + (not (sm/valid-safe-int? index)) (u/display-not-valid :setRow-index index) (not (contains? ctl/grid-track-types type)) (u/display-not-valid :setRow-type 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) (not (r/check-permission plugin-id "content:write")) @@ -393,10 +393,10 @@ (not (shape-proxy? 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) - (or (< column 0) (not (us/safe-int? column))) + (or (< column 0) (not (sm/valid-safe-int? column))) (u/display-not-valid :appendChild-column column) (not (r/check-permission plugin-id "content:write")) @@ -431,7 +431,7 @@ (let [cell (locate-cell self) shape (u/proxy->shape self)] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :row-value value) (nil? cell) @@ -451,7 +451,7 @@ (let [shape (u/proxy->shape self) cell (locate-cell self)] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :rowSpan-value value) (nil? cell) @@ -471,7 +471,7 @@ (let [shape (u/proxy->shape self) cell (locate-cell self)] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :column-value value) (nil? cell) @@ -491,7 +491,7 @@ (let [shape (u/proxy->shape self) cell (locate-cell self)] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :columnSpan-value value) (nil? cell) diff --git a/frontend/src/app/plugins/page.cljs b/frontend/src/app/plugins/page.cljs index 34494be6d8..e6c9f95bab 100644 --- a/frontend/src/app/plugins/page.cljs +++ b/frontend/src/app/plugins/page.cljs @@ -10,7 +10,7 @@ [app.common.data.macros :as dm] [app.common.files.helpers :as cfh] [app.common.geom.point :as gpt] - [app.common.spec :as us] + [app.common.schema :as sm] [app.common.types.color :as cc] [app.common.uuid :as uuid] [app.main.data.comments :as dc] @@ -299,7 +299,7 @@ (fn [orientation value board] (let [shape (u/proxy->shape board)] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :addRulerGuide "Value not a safe number") (not (contains? #{"vertical" "horizontal"} orientation)) @@ -345,8 +345,8 @@ (or (not (string? content)) (empty? content)) (u/display-not-valid :addCommentThread "Content not valid") - (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 :addCommentThread "Position not valid") (and (some? board) (or (not (shape/shape-proxy? board)) (not (cfh/frame-shape? shape)))) diff --git a/frontend/src/app/plugins/ruler_guides.cljs b/frontend/src/app/plugins/ruler_guides.cljs index 834280c2a8..d9c8e7c6c4 100644 --- a/frontend/src/app/plugins/ruler_guides.cljs +++ b/frontend/src/app/plugins/ruler_guides.cljs @@ -8,7 +8,7 @@ (:require [app.common.data.macros :as dm] [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.store :as st] [app.plugins.format :as format] @@ -77,7 +77,7 @@ :set (fn [self value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :position "Not valid position") (not (r/check-permission plugin-id "content:write")) diff --git a/frontend/src/app/plugins/shape.cljs b/frontend/src/app/plugins/shape.cljs index b047954397..a75b245365 100644 --- a/frontend/src/app/plugins/shape.cljs +++ b/frontend/src/app/plugins/shape.cljs @@ -14,7 +14,6 @@ [app.common.path-names :as cpn] [app.common.record :as crc] [app.common.schema :as sm] - [app.common.spec :as us] [app.common.svg.path :as svg.path] [app.common.types.color :as clr] [app.common.types.component :as ctk] @@ -325,7 +324,7 @@ (fn [self value] (let [id (obj/get self "$id")] (cond - (or (not (us/safe-int? value)) (< value 0)) + (or (not (sm/valid-safe-int? value)) (< value 0)) (u/display-not-valid :borderRadius value) (not (r/check-permission plugin-id "content:write")) @@ -341,7 +340,7 @@ (fn [self value] (let [id (obj/get self "$id")] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :borderRadiusTopLeft value) (not (r/check-permission plugin-id "content:write")) @@ -357,7 +356,7 @@ (fn [self value] (let [id (obj/get self "$id")] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :borderRadiusTopRight value) (not (r/check-permission plugin-id "content:write")) @@ -373,7 +372,7 @@ (fn [self value] (let [id (obj/get self "$id")] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :borderRadiusBottomRight value) (not (r/check-permission plugin-id "content:write")) @@ -389,7 +388,7 @@ (fn [self value] (let [id (obj/get self "$id")] (cond - (not (us/safe-int? value)) + (not (sm/valid-safe-int? value)) (u/display-not-valid :borderRadiusBottomLeft value) (not (r/check-permission plugin-id "content:write")) @@ -405,7 +404,7 @@ (fn [self value] (let [id (obj/get self "$id")] (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) (not (r/check-permission plugin-id "content:write")) @@ -492,7 +491,7 @@ (fn [self value] (let [id (obj/get self "$id")] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :x value) (not (r/check-permission plugin-id "content:write")) @@ -510,7 +509,7 @@ (fn [self value] (let [id (obj/get self "$id")] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :y value) (not (r/check-permission plugin-id "content:write")) @@ -555,7 +554,7 @@ :set (fn [self value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :parentX value) (not (r/check-permission plugin-id "content:write")) @@ -582,7 +581,7 @@ :set (fn [self value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :parentY value) (not (r/check-permission plugin-id "content:write")) @@ -609,7 +608,7 @@ :set (fn [self value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :frameX value) (not (r/check-permission plugin-id "content:write")) @@ -636,7 +635,7 @@ :set (fn [self value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :frameY value) (not (r/check-permission plugin-id "content:write")) @@ -795,10 +794,10 @@ :resize (fn [width height] (cond - (or (not (us/safe-number? width)) (<= width 0)) + (or (not (sm/valid-safe-number? width)) (<= width 0)) (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) (not (r/check-permission plugin-id "content:write")) @@ -1048,10 +1047,10 @@ (not (cfh/text-shape? shape)) (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) - (not (us/safe-int? end)) + (not (sm/valid-safe-int? end)) (u/display-not-valid :getRange-end end) :else @@ -1078,7 +1077,7 @@ :setParentIndex (fn [index] (cond - (not (us/safe-int? index)) + (not (sm/valid-safe-int? index)) (u/display-not-valid :setParentIndex index) (not (r/check-permission plugin-id "content:write")) @@ -1230,7 +1229,7 @@ (fn [orientation value] (let [shape (u/locate-shape file-id page-id id)] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :addRulerGuide "Value not a safe number") (not (contains? #{"vertical" "horizontal"} orientation)) diff --git a/frontend/src/app/plugins/viewport.cljs b/frontend/src/app/plugins/viewport.cljs index bacd9c90a1..a581e3ba60 100644 --- a/frontend/src/app/plugins/viewport.cljs +++ b/frontend/src/app/plugins/viewport.cljs @@ -7,7 +7,7 @@ (ns app.plugins.viewport (:require [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.zoom :as dwz] [app.main.store :as st] @@ -37,10 +37,10 @@ (let [new-x (obj/get value "x") new-y (obj/get value "y")] (cond - (not (us/safe-number? new-x)) + (not (sm/valid-safe-number? 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) :else @@ -62,7 +62,7 @@ :set (fn [value] (cond - (not (us/safe-number? value)) + (not (sm/valid-safe-number? value)) (u/display-not-valid :zoom value) :else