I’d like to leverage the spec library to validate form input. The idea is to update values in re-frame’s db, validate against spec, and display the corresponding error message. While explain-data
get me close, it doesn’t quite provide the functionality I need. With the following example, I understand that the issue is the missing ::last-name
, but that’s more involved to programmatically determine. Does anyone know of a way to achieve the desired goal? Thanks.
(require '[cljs.spec.alpha :as s])
(s/def ::first-name string?)
(s/def ::last-name string?)
(s/def ::person (s/keys :req [::first-name ::last-name]))
(def p1 {::first-name "Ari"})
(:cljs.spec.alpha/problems (s/explain-data ::person p1))