🐛 Fix variant validation when nil
Some checks failed
Commit Message Check / Check Commit Message (push) Has been cancelled

This commit is contained in:
Pablo Alba
2025-10-22 21:36:55 +02:00
committed by Andrey Antukh
parent 879caf66eb
commit 245190f4f9

View File

@@ -438,6 +438,7 @@
children (map #(ctst/get-shape page %) shapes) children (map #(ctst/get-shape page %) shapes)
prop-names (cfv/extract-properties-names (first children) (:data file))] prop-names (cfv/extract-properties-names (first children) (:data file))]
(doseq [child children] (doseq [child children]
(when child
(if (not (ctk/is-variant? child)) (if (not (ctk/is-variant? child))
(report-error :not-a-variant (report-error :not-a-variant
(str/ffmt "Shape % should be a variant" (:id child)) (str/ffmt "Shape % should be a variant" (:id child))
@@ -450,7 +451,7 @@
(when (not= prop-names (cfv/extract-properties-names child (:data file))) (when (not= prop-names (cfv/extract-properties-names child (:data file)))
(report-error :invalid-variant-properties (report-error :invalid-variant-properties
(str/ffmt "Variant % has invalid properties %" (:id child) (vec prop-names)) (str/ffmt "Variant % has invalid properties %" (:id child) (vec prop-names))
child file page))))))) child file page))))))))
(defn- check-variant (defn- check-variant
"Shape is a variant, so "Shape is a variant, so
@@ -599,7 +600,8 @@
main-component (if (:deleted component) main-component (if (:deleted component)
(dm/get-in component [:objects (:main-instance-id component)]) (dm/get-in component [:objects (:main-instance-id component)])
(ctst/get-shape component-page (:main-instance-id component)))] (ctst/get-shape component-page (:main-instance-id component)))]
(when-not (ctk/is-variant? main-component) (when (and main-component
(not (ctk/is-variant? main-component)))
(report-error :not-a-variant (report-error :not-a-variant
(str/ffmt "Shape % should be a variant" (:id main-component)) (str/ffmt "Shape % should be a variant" (:id main-component))
main-component file component-page)))) main-component file component-page))))