mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
Move over helper
This commit is contained in:
parent
5de1f450c1
commit
b3e73b9abc
2 changed files with 9 additions and 7 deletions
|
@ -143,6 +143,14 @@
|
||||||
(map second)
|
(map second)
|
||||||
(into #{})))
|
(into #{})))
|
||||||
|
|
||||||
|
(defn token-value-self-reference?
|
||||||
|
"Check if the token is self referencing with its `token-name` in `token-value`.
|
||||||
|
Simple 1 level check, doesn't account for circular self refernces across multiple tokens."
|
||||||
|
[token-name token-value]
|
||||||
|
(let [token-references (find-token-value-references token-value)
|
||||||
|
self-reference? (get token-references token-name)]
|
||||||
|
self-reference?))
|
||||||
|
|
||||||
(defn group-by-type [tokens]
|
(defn group-by-type [tokens]
|
||||||
(let [tokens' (if (or (map? tokens)
|
(let [tokens' (if (or (map? tokens)
|
||||||
(d/ordered-map? tokens))
|
(d/ordered-map? tokens))
|
||||||
|
|
|
@ -91,12 +91,6 @@ Token names should only contain letters and digits separated by . characters.")}
|
||||||
|
|
||||||
;; Component -------------------------------------------------------------------
|
;; Component -------------------------------------------------------------------
|
||||||
|
|
||||||
(defn token-self-reference?
|
|
||||||
[token-name input]
|
|
||||||
(let [token-references (ctob/find-token-value-references input)
|
|
||||||
self-reference? (get token-references token-name)]
|
|
||||||
self-reference?))
|
|
||||||
|
|
||||||
(defn validate-token-value+
|
(defn validate-token-value+
|
||||||
"Validates token value by resolving the value `input` using `StyleDictionary`.
|
"Validates token value by resolving the value `input` using `StyleDictionary`.
|
||||||
Returns a promise of either resolved tokens or rejects with an error state."
|
Returns a promise of either resolved tokens or rejects with an error state."
|
||||||
|
@ -108,7 +102,7 @@ Token names should only contain letters and digits separated by . characters.")}
|
||||||
(empty? (str/trim value))
|
(empty? (str/trim value))
|
||||||
(p/rejected {:errors [{:error/code :error/empty-input}]})
|
(p/rejected {:errors [{:error/code :error/empty-input}]})
|
||||||
|
|
||||||
(token-self-reference? token-name value)
|
(ctob/token-value-self-reference? token-name value)
|
||||||
(p/rejected {:errors [(wte/get-error-code :error.token/direct-self-reference)]})
|
(p/rejected {:errors [(wte/get-error-code :error.token/direct-self-reference)]})
|
||||||
|
|
||||||
:else
|
:else
|
||||||
|
|
Loading…
Add table
Reference in a new issue