diff --git a/backend/src/app/config.clj b/backend/src/app/config.clj index 10bc7e4b7..e61d7dd49 100644 --- a/backend/src/app/config.clj +++ b/backend/src/app/config.clj @@ -84,7 +84,7 @@ ;; a server prop key where initial project is stored. :initial-project-skey "initial-project"}) -(s/def ::flags ::us/vec-of-keywords) +(s/def ::flags ::us/vec-of-valid-keywords) ;; DEPRECATED PROPERTIES (s/def ::telemetry-enabled ::us/boolean) @@ -93,7 +93,7 @@ (s/def ::audit-log-archive-uri ::us/string) (s/def ::audit-log-gc-max-age ::dt/duration) -(s/def ::admins ::us/set-of-str) +(s/def ::admins ::us/set-of-non-empty-strings) (s/def ::file-change-snapshot-every ::us/integer) (s/def ::file-change-snapshot-timeout ::dt/duration) @@ -128,8 +128,8 @@ (s/def ::oidc-token-uri ::us/string) (s/def ::oidc-auth-uri ::us/string) (s/def ::oidc-user-uri ::us/string) -(s/def ::oidc-scopes ::us/set-of-str) -(s/def ::oidc-roles ::us/set-of-str) +(s/def ::oidc-scopes ::us/set-of-non-empty-strings) +(s/def ::oidc-roles ::us/set-of-non-empty-strings) (s/def ::oidc-roles-attr ::us/keyword) (s/def ::oidc-email-attr ::us/keyword) (s/def ::oidc-name-attr ::us/keyword) @@ -165,7 +165,7 @@ (s/def ::profile-complaint-threshold ::us/integer) (s/def ::public-uri ::us/string) (s/def ::redis-uri ::us/string) -(s/def ::registration-domain-whitelist ::us/set-of-str) +(s/def ::registration-domain-whitelist ::us/set-of-non-empty-strings) (s/def ::rlimit-font ::us/integer) (s/def ::rlimit-file-update ::us/integer) (s/def ::rlimit-image ::us/integer) diff --git a/backend/src/app/http/assets.clj b/backend/src/app/http/assets.clj index 9061c436d..39a55c719 100644 --- a/backend/src/app/http/assets.clj +++ b/backend/src/app/http/assets.clj @@ -29,7 +29,7 @@ (defn coerce-id [id] - (let [res (us/uuid-conformer id)] + (let [res (parse-uuid id)] (when-not (uuid? res) (ex/raise :type :not-found :hint "object not found")) diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj index 1b1002dce..11a29f892 100644 --- a/backend/src/app/http/debug.clj +++ b/backend/src/app/http/debug.clj @@ -9,7 +9,6 @@ (:require [app.common.exceptions :as ex] [app.common.pprint :as pp] - [app.common.spec :as us] [app.common.uuid :as uuid] [app.config :as cf] [app.db :as db] @@ -205,7 +204,7 @@ [{:keys [pool]} request] (letfn [(parse-id [request] (let [id (get-in request [:path-params :id]) - id (us/uuid-conformer id)] + id (parse-uuid id)] (when (uuid? id) id))) diff --git a/backend/src/app/rpc/mutations/teams.clj b/backend/src/app/rpc/mutations/teams.clj index 4657a425a..7be2a96aa 100644 --- a/backend/src/app/rpc/mutations/teams.clj +++ b/backend/src/app/rpc/mutations/teams.clj @@ -353,7 +353,7 @@ (declare create-team-invitation) (s/def ::email ::us/email) -(s/def ::emails ::us/set-of-emails) +(s/def ::emails ::us/set-of-valid-emails) (s/def ::invite-team-member (s/keys :req-un [::profile-id ::team-id ::role] :opt-un [::email ::emails])) @@ -443,7 +443,7 @@ ;; --- Mutation: Create Team & Invite Members -(s/def ::emails ::us/set-of-emails) +(s/def ::emails ::us/set-of-valid-emails) (s/def ::create-team-and-invite-members (s/and ::create-team (s/keys :req-un [::emails ::role]))) diff --git a/common/src/app/common/spec.cljc b/common/src/app/common/spec.cljc index 0dfd68648..654270206 100644 --- a/common/src/app/common/spec.cljc +++ b/common/src/app/common/spec.cljc @@ -133,7 +133,7 @@ (dm/str v))] (s/def ::rgb-color-str (s/conformer conformer unformer))) -;; --- SPEC: set of Keywords +;; --- SPEC: set/vec of valid Keywords (letfn [(conform-fn [dest s] (let [xform (keep (fn [s] @@ -146,17 +146,17 @@ (string? s) (into dest xform (str/words s)) :else ::s/invalid)))] - (s/def ::set-of-keywords + (s/def ::set-of-valid-keywords (s/conformer (fn [s] (conform-fn #{} s)) (fn [s] (str/join " " (map name s))))) - (s/def ::vec-of-keywords + (s/def ::vec-of-valid-keywords (s/conformer (fn [s] (conform-fn [] s)) (fn [s] (str/join " " (map name s)))))) -;; --- SPEC: set-of-emails +;; --- SPEC: set-of-valid-emails (letfn [(conformer [v] (cond @@ -171,9 +171,9 @@ :else ::s/invalid)) (unformer [v] (str/join " " v))] - (s/def ::set-of-emails (s/conformer conformer unformer))) + (s/def ::set-of-valid-emails (s/conformer conformer unformer))) -;; --- SPEC: set-of-str +;; --- SPEC: set-of-non-empty-strings (def non-empty-strings-xf (comp @@ -189,7 +189,7 @@ :else ::s/invalid)) (unformer [s] (str/join "," s))] - (s/def ::set-of-str (s/conformer conformer unformer))) + (s/def ::set-of-non-empty-strings (s/conformer conformer unformer))) ;; --- SPECS WITHOUT CONFORMER @@ -200,7 +200,6 @@ (s/def ::fn fn?) (s/def ::id ::uuid) -;; NOTE: this is a coercerless version of `::set-of-str` spec (s/def ::set-of-string (s/every ::string :kind set?)) (s/def ::coll-of-uuid (s/every ::uuid)) (s/def ::set-of-uuid (s/every ::uuid :kind set?)) diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index 51880b3b0..33dce462a 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -452,9 +452,9 @@ (defn invite-team-members [{:keys [emails role team-id resend?] :as params}] - (us/assert ::us/set-of-emails emails) - (us/assert ::us/keyword role) - (us/assert ::us/uuid team-id) + (us/assert! ::us/set-of-valid-emails emails) + (us/assert! ::us/keyword role) + (us/assert! ::us/uuid team-id) (ptk/reify ::invite-team-members IDeref (-deref [_] {:role role :team-id team-id :resend? resend?}) diff --git a/frontend/src/app/main/ui/dashboard/team.cljs b/frontend/src/app/main/ui/dashboard/team.cljs index 939b6e2d1..4281a8219 100644 --- a/frontend/src/app/main/ui/dashboard/team.cljs +++ b/frontend/src/app/main/ui/dashboard/team.cljs @@ -77,7 +77,7 @@ ] (filterv identity))) -(s/def ::emails (s/and ::us/set-of-emails d/not-empty?)) +(s/def ::emails (s/and ::us/set-of-valid-emails d/not-empty?)) (s/def ::role ::us/keyword) (s/def ::team-id ::us/uuid) diff --git a/frontend/src/app/main/ui/onboarding/team_choice.cljs b/frontend/src/app/main/ui/onboarding/team_choice.cljs index 55c5f56b8..944e074aa 100644 --- a/frontend/src/app/main/ui/onboarding/team_choice.cljs +++ b/frontend/src/app/main/ui/onboarding/team_choice.cljs @@ -96,7 +96,7 @@ [{:value "editor" :label (tr "labels.editor")} {:value "admin" :label (tr "labels.admin")}]) -(s/def ::emails (s/and ::us/set-of-emails d/not-empty?)) +(s/def ::emails (s/and ::us/set-of-valid-emails d/not-empty?)) (s/def ::role ::us/keyword) (s/def ::invite-form (s/keys :req-un [::role ::emails])) @@ -180,10 +180,10 @@ [:div.action (tr "onboarding.choice.team-up.invite-members-skip")]]]] [:& team-modal-right] [:div.paginator "2/2"] - + [:img.deco.square {:src "images/deco-square.svg" :border "0"}] [:img.deco.circle {:src "images/deco-circle.svg" :border "0"}] [:img.deco.line1 {:src "images/deco-line1.svg" :border "0"}] [:img.deco.line2 {:src "images/deco-line2.svg" :border "0"}]]])) - +