@@ -5,6 +5,7 @@ A minimalist data driven data model library, inspired by [Clojure Spec](https://
55[ ![ Clojars Project] ( https://img.shields.io/clojars/v/minimallist.svg )] ( https://clojars.org/minimallist )
66[ ![ cljdoc badge] ( https://cljdoc.org/badge/minimallist/minimallist )] ( https://cljdoc.org/d/minimallist/minimallist/CURRENT )
77[ ![ project chat] ( https://img.shields.io/badge/slack-join_chat-brightgreen.svg )] ( https://clojurians.slack.com/archives/C012HUX1VPC )
8+ [ ![ cljdoc badge] ( https://img.shields.io/clojars/dt/minimallist?color=opal )] ( https://clojars.org/minimallist )
89
910## Usage
1011
@@ -14,29 +15,37 @@ A minimalist data driven data model library, inspired by [Clojure Spec](https://
1415 [minimallist.helper :as h]))
1516
1617(def hiccup-model
17- (h/let ['hiccup (h/alt [:node (h/in-vector (h/cat (h/fn keyword?)
18- (h/? (h/map ))
19- (h/* (h/not-inlined (h/ref 'hiccup)))))]
20- [:primitive (h/alt (h/fn nil?)
21- (h/fn boolean?)
22- (h/fn number?)
23- (h/fn string?))])]
18+ (h/let ['hiccup (h/alt [:node (h/in-vector (h/cat [ :name (h/fn keyword?)]
19+ [ :props (h/? (h/map-of ( h/fn keyword?) ( h/fn any?)))]
20+ [ :children (h/* (h/not-inlined (h/ref 'hiccup)))] ))]
21+ [:primitive (h/alt [ :nil (h/fn nil?)]
22+ [ :boolean (h/fn boolean?)]
23+ [ :number (h/fn number?)]
24+ [ :text (h/fn string?)] )])]
2425 (h/ref 'hiccup)))
2526
2627(valid? hiccup-model [:div {:class [:foo :bar ]}
2728 [:p " Hello, world of data" ]])
2829; => true
30+
31+ (describe hiccup-model [:div {:class [:foo :bar ]}
32+ [:p " Hello, world of data" ]])
33+ ; => [:node {:name :div,
34+ ; :props [{:class [:foo :bar]}],
35+ ; :children [[:node {:name :p
36+ ; :props []
37+ ; :children [[:primitive [:text "Hello, world of data"]]]}]]}]
2938```
3039
3140## Features
3241
33- - validates and generates data,
42+ - validates, parses and generates data,
3443- fully data driven, models are hash-map based created via helpers,
3544- support recursive definitions and sequence regex,
3645- no macro, no static registry, pure functions,
3746- relatively simple implementation, easy to read and modify,
3847- cross platform (` .cljc ` ),
39- - ` valid? ` runs in [ Babashka] ( https://github.com/borkdude/babashka )
48+ - ` valid? ` and ` describe ` run in [ Babashka] ( https://github.com/borkdude/babashka )
4049
4150## Non-goals (for now)
4251
@@ -48,7 +57,7 @@ A minimalist data driven data model library, inspired by [Clojure Spec](https://
4857See the [ latest documentation on cljdoc] ( https://cljdoc.org/d/minimallist/minimallist/CURRENT ) for:
4958- A general description of the Minimallist project.
5059- How to use the helpers to build your models.
51- - How to validate and generate your data.
60+ - How to validate, parse and generate your data.
5261
5362## Status
5463
0 commit comments