Skip to content

Commit 90ceb30

Browse files
committed
Prepare for v0.0.4 release.
1 parent 59dc04b commit 90ceb30

File tree

6 files changed

+51
-11
lines changed

6 files changed

+51
-11
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ Versions prior to v0.1.0 are considered experimental, their API may change.
77

88
## [Unreleased]
99

10+
11+
## [0.0.4] - 2020-08-09
12+
1013
### Added
1114
- this changelog file.
1215
- the models `gen/fn-simple-symbol`, `gen/fn-qualified-symbol`,
1316
`gen/fn-simple-keyword` and `gen/fn-qualified-keyword`.
17+
- the `describe` function, for parsing data.
1418

1519
### Changed
1620
- the models `gen/fn-symbol`, `gen/fn-keyword` now generate qualified symbols and keywords,

README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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://
4857
See 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

doc/babashka.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ As a babashka shell script:
1818
(m/valid? (h/fn int?) 1) ;=> true
1919
(m/valid? (h/fn int?) "1") ;=> false
2020

21+
(m/describe (h/fn int?) 1) ;=> 1
22+
(m/describe (h/fn int?) "1") ;=> :invalid
23+
2124
;; Does not work for now.
2225
;(require '[clojure.test.check.generators :as tcg])
2326
;(require '[minimallist.generator :as mg])

doc/cljdoc.edn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
["Model Anatomy" {:file "doc/model_anatomy.md"}]
66
["Model Builder" {:file "doc/model_builder.md"}]
77
["Data Validation" {:file "doc/data_validation.md"}]
8+
["Data Parsing" {:file "doc/data_parsing.md"}]
89
["Data Generation" {:file "doc/data_generation.md"}]
910
["Usage in Babashka" {:file "doc/babashka.md"}]]}

doc/data_parsing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Data Parsing
2+
3+
```clojure
4+
(require '[minimallist.core :refer [describe]])
5+
(require '[minimallist.helper :as h])
6+
7+
(describe (h/fn string?) "Hello, world!")
8+
;=> "Hello, world"
9+
10+
(describe (h/cat (h/fn int?)
11+
(h/alt [:option1 (h/fn string?)]
12+
[:option2 (h/fn keyword?)]
13+
[:option3 (h/cat (h/fn string?)
14+
(h/fn keyword?))])
15+
(h/fn int?))
16+
[1 "a" :b 3])
17+
;=> [1 [:option3 ["a" :b]] 3]
18+
```
19+
20+
A more complete documentation will come later.
21+
22+
In the mean time, please take a look at the test files
23+
for more examples.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>minimallist</groupId>
55
<artifactId>minimallist</artifactId>
6-
<version>0.0.3</version>
6+
<version>0.0.4</version>
77
<name>Minimallist</name>
88
<description>A minimalist data driven data model library, inspired by Spec and Malli.</description>
99
<url>https://github.com/green-coder/minimallist</url>

0 commit comments

Comments
 (0)