A minimalist data driven data model library, inspired by Clojure Spec and Malli.
(ns your-namespace
(:require [minimallist.core :refer [valid? describe]]
[minimallist.helper :as h]))
(def hiccup-model
(h/let ['hiccup (h/alt [:node (h/in-vector (h/cat [:name (h/fn keyword?)]
[:props (h/? (h/map-of (h/vector (h/fn keyword?) (h/fn any?))))]
[:children (h/* (h/not-inlined (h/ref 'hiccup)))]))]
[:primitive (h/alt [:nil (h/fn nil?)]
[:boolean (h/fn boolean?)]
[:number (h/fn number?)]
[:text (h/fn string?)])])]
(h/ref 'hiccup)))
(valid? hiccup-model [:div {:class [:foo :bar]}
[:p "Hello, world of data"]])
;=> true
(describe hiccup-model [:div {:class [:foo :bar]}
[:p "Hello, world of data"]])
;=> [:node {:name :div
; :props [[[:class [:foo :bar]]]]
; :children [[:node {:name :p
; :props []
; :children [[:primitive [:text "Hello, world of data"]]]}]]}]
.cljc
),valid?
and describe
run in BabashkaSee the latest documentation on cljdoc for:
This is a work in progress, the API may change in the future.
More functionalities will be added later, once the API design is more stable.
If you find any bug or have comments, please create an issue in GitHub.
The Minimallist library is developed by Vincent Cantin. It is distributed under the terms of the Eclipse Public License version 2.0.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close