@@ -5,6 +5,7 @@ A minimalist data driven data model library, inspired by [Clojure Spec](https://
5
5
[ ![ Clojars Project] ( https://img.shields.io/clojars/v/minimallist.svg )] ( https://clojars.org/minimallist )
6
6
[ ![ cljdoc badge] ( https://cljdoc.org/badge/minimallist/minimallist )] ( https://cljdoc.org/d/minimallist/minimallist/CURRENT )
7
7
[ ![ 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 )
8
9
9
10
## Usage
10
11
@@ -14,29 +15,37 @@ A minimalist data driven data model library, inspired by [Clojure Spec](https://
14
15
[minimallist.helper :as h]))
15
16
16
17
(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?)] )])]
24
25
(h/ref 'hiccup)))
25
26
26
27
(valid? hiccup-model [:div {:class [:foo :bar ]}
27
28
[:p " Hello, world of data" ]])
28
29
; => 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"]]]}]]}]
29
38
```
30
39
31
40
## Features
32
41
33
- - validates and generates data,
42
+ - validates, parses and generates data,
34
43
- fully data driven, models are hash-map based created via helpers,
35
44
- support recursive definitions and sequence regex,
36
45
- no macro, no static registry, pure functions,
37
46
- relatively simple implementation, easy to read and modify,
38
47
- 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 )
40
49
41
50
## Non-goals (for now)
42
51
@@ -48,7 +57,7 @@ A minimalist data driven data model library, inspired by [Clojure Spec](https://
48
57
See the [ latest documentation on cljdoc] ( https://cljdoc.org/d/minimallist/minimallist/CURRENT ) for:
49
58
- A general description of the Minimallist project.
50
59
- 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.
52
61
53
62
## Status
54
63
0 commit comments