mirror of
https://github.com/logseq/logseq.git
synced 2026-05-04 10:56:32 +00:00
- Added to CI now that it passes - Added no-doc for docstrings that don't add any more than what's in the ns name or for ones where I didn't know the ns that well
29 lines
903 B
Clojure
29 lines
903 B
Clojure
(ns frontend.spec
|
|
"Clojure spec related setup and helpers"
|
|
(:require [cljs.spec.alpha :as s]
|
|
[frontend.config :as config]
|
|
[lambdaisland.glogi :as log]
|
|
[expound.alpha :as expound]))
|
|
|
|
;; Enabled for all environments. We want asserts to run in production e.g.
|
|
;; frontend.storage one is preventing data corruption. If we introduce asserts
|
|
;; that are not perf sensitive, we will need to reconsider.
|
|
(s/check-asserts true)
|
|
|
|
(set! s/*explain-out* expound/printer)
|
|
|
|
(defn validate
|
|
"This function won't crash the current thread, just log error."
|
|
[spec value]
|
|
(when config/dev?
|
|
(if (s/explain-data spec value)
|
|
(let [error-message (expound/expound-str spec value)
|
|
ex (ex-info "Error in validate" {:value value})]
|
|
(log/error :exception ex :spec/validate-failed error-message)
|
|
false)
|
|
true)))
|
|
|
|
;; repo
|
|
|
|
(s/def :repos/url string?)
|