mirror of
https://github.com/penpot/penpot.git
synced 2026-08-05 20:38:38 +00:00
✨ Reuse file data checkers on file validate ns
This commit is contained in:
parent
3df557b370
commit
fbf63b98c3
@ -650,26 +650,12 @@
|
|||||||
(check-component component file)
|
(check-component component file)
|
||||||
(deref *errors*)))
|
(deref *errors*)))
|
||||||
|
|
||||||
(def ^:private valid-fdata?
|
|
||||||
"Structural validation of file data using defined schema"
|
|
||||||
(sm/lazy-validator ::ctf/data))
|
|
||||||
|
|
||||||
(def ^:private get-fdata-explain
|
|
||||||
"Get schema explain data for file data"
|
|
||||||
(sm/lazy-explainer ::ctf/data))
|
|
||||||
|
|
||||||
(defn validate-file-schema!
|
(defn validate-file-schema!
|
||||||
"Validates the file itself, without external dependencies, it
|
"Validates the file itself, without external dependencies, it
|
||||||
performs the schema checking and some semantical validation of the
|
performs the schema checking and some semantical validation of the
|
||||||
content."
|
content."
|
||||||
[{:keys [id data] :as file}]
|
[file]
|
||||||
(when-not (valid-fdata? data)
|
(update file :data ctf/check-file-data))
|
||||||
(ex/raise :type :validation
|
|
||||||
:code :schema-validation
|
|
||||||
:hint (str/ffmt "invalid file data structure found on file '%'" id)
|
|
||||||
:file-id id
|
|
||||||
::sm/explain (get-fdata-explain data)))
|
|
||||||
file)
|
|
||||||
|
|
||||||
(defn validate-file!
|
(defn validate-file!
|
||||||
"Validate full referential integrity and semantic coherence on file data.
|
"Validate full referential integrity and semantic coherence on file data.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user