Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/green-coder/minimallist
A minimalist data driven data model library, inspired by Clojure Spec and Malli.
https://github.com/green-coder/minimallist
clojure clojurescript data-parsing data-validation
Last synced: 3 days ago
JSON representation
A minimalist data driven data model library, inspired by Clojure Spec and Malli.
- Host: GitHub
- URL: https://github.com/green-coder/minimallist
- Owner: green-coder
- License: epl-2.0
- Created: 2020-04-15T18:05:28.000Z (almost 5 years ago)
- Default Branch: all-work-and-no-play
- Last Pushed: 2024-07-07T07:59:16.000Z (7 months ago)
- Last Synced: 2024-10-15T15:18:10.122Z (3 months ago)
- Topics: clojure, clojurescript, data-parsing, data-validation
- Language: Clojure
- Homepage:
- Size: 203 KB
- Stars: 66
- Watchers: 4
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Minimallist [![CircleCI](https://circleci.com/gh/green-coder/minimallist.svg?style=svg)](https://circleci.com/gh/green-coder/minimallist)
A minimalist data driven data model library, inspired by [Clojure Spec](https://clojure.org/guides/spec) and [Malli](https://github.com/metosin/malli).
[![Clojars Project](https://img.shields.io/clojars/v/minimallist.svg)](https://clojars.org/minimallist)
[![cljdoc badge](https://cljdoc.org/badge/minimallist/minimallist)](https://cljdoc.org/d/minimallist/minimallist/CURRENT)
[![project chat](https://img.shields.io/badge/slack-join_chat-brightgreen.svg)](https://clojurians.slack.com/archives/C012HUX1VPC)
[![cljdoc badge](https://img.shields.io/clojars/dt/minimallist?color=opal)](https://clojars.org/minimallist)## Usage
```clojure
(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"]]]}]]}]
```## Features
- validates, parses and generates data,
- fully data driven, models are hash-map based created via helpers,
- support recursive definitions and sequence regex,
- no macro, no static registry, pure functions,
- relatively simple implementation, easy to read and modify,
- cross platform (`.cljc`),
- `valid?` and `describe` run in [Babashka](https://github.com/borkdude/babashka)## Non-goals (for now)
- does not integrate with anything else,
- does not try hard to be performant## Documentation
See the [latest documentation on cljdoc](https://cljdoc.org/d/minimallist/minimallist/CURRENT) for:
- A general description of the Minimallist project.
- How to use the helpers to build your models.
- How to validate, parse and generate your data.## Status
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.
## License
The Minimallist library is developed by Vincent Cantin.
It is distributed under the terms of the Eclipse Public License version 2.0.