Skip to content

Commit

Permalink
Merge branch 'master' of github.com:metosin/malli into property-regis…
Browse files Browse the repository at this point in the history
…try-into-schema
  • Loading branch information
frenchy64 committed Jul 16, 2024
2 parents 05f0479 + 0dd2e0d commit da7cbb0
Show file tree
Hide file tree
Showing 36 changed files with 1,253 additions and 419 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ jobs:
with:
distribution: zulu
java-version: ${{ matrix.jdk }}
cache: maven
- uses: actions/cache@v4
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-${{ matrix.clojure }}-${{ matrix.jdk }}
restore-keys: |
${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-${{ matrix.clojure }}-
${{ runner.os }}-test-deps-
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
Expand All @@ -48,7 +56,14 @@ jobs:
with:
distribution: zulu
java-version: 11
cache: maven
- uses: actions/cache@v4
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}
restore-keys: |
${{ runner.os }}-test-deps-
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
Expand All @@ -73,7 +88,16 @@ jobs:
with:
distribution: zulu
java-version: 11
cache: maven
- uses: actions/cache@v4
with:
path: |
~/.m2/repository
~/.deps.clj
~/.gitlibs
key: ${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-${{ hashFiles('**/bb.edn') }}
restore-keys: |
${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-
${{ runner.os }}-test-deps-
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
Expand Down
54 changes: 48 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,48 @@ We use [Break Versioning][breakver]. The version numbers follow a `<major>.<mino

Malli is in well matured [alpha](README.md#alpha).

## UNRELEASED

* `:->` added to dedault registry, also to [documentation](docs/function-schemas.md#flat-arrow-function-schemas).

## 0.16.2 (2024-06-30)

* Experimental `:->` for simpler function defintions (not available on default schema registry) [#1027](https://github.com/metosin/malli/pull/1027)

```clojure
[:-> :any] ; [:=> :cat :any]
[:-> :int :any] ; [:=> [:cat :int] :any]
[:-> [:cat :int] :any] ; [:=> [:cat [:cat :int]] :any]
[:-> a b c d :any] ; [:=> [:cat a b c d] :any]

;; guard property
[:-> {:guard (fn [[[arg] ret]] ...)} :string :boolean]
; [:=> [:cat :string] :boolean [:fn (fn [[[arg] ret]] ...)]]
```

* Fix `mu/get-in` for false-y keys [#1065](https://github.com/metosin/malli/pull/1065)
* Add `:float` [#1055](https://github.com/metosin/malli/pull/1055)
* Make clj-kondo dir configurable [#1062](https://github.com/metosin/malli/pull/1062)
* Improve doc for transformers [#1058](https://github.com/metosin/malli/pull/1058)
* `:double` generates Long if `:`min is Long [#1034](https://github.com/metosin/malli/issues/1034)
* Fix Swagger definitions collecting [#1002](https://github.com/metosin/malli/issues/1002)

## 0.16.1 (2024-04-30)

* Enabled Java8 tests back, no need to limit the version.

## 0.16.0 (2024-04-20)

* **BREAKING**: minimum Java-version is now Java11
* allow changing prefix of json-schema $refs via option `:malli.json-schema/definitions-path` [#1045](https://github.com/metosin/malli/pull/1045)
* Inline refs in non-`:body` swagger parameters [#1044](https://github.com/metosin/malli/pull/1044)
* Fix flaky test [#1040](https://github.com/metosin/malli/pull/1040)
* Utility to update entry properties: `mu/update-entry-properties` [#1037](https://github.com/metosin/malli/pull/1037)
* Fix actions cache [#1036](https://github.com/metosin/malli/pull/1036)
* Only humanize one of `:min` / `:max` when different [#1032](https://github.com/metosin/malli/pull/1032)
* Distinguish between symbols and strings in humanize [#1031](https://github.com/metosin/malli/pull/1031)
* Fix `:map-of` `:min` and unreachable generator, explain such-that failures [#1029](https://github.com/metosin/malli/pull/1029)

## 0.15.0 (2024-03-23)

* `:=>` takes optional 3rd child, the guard schema validating vector of arguments and return value `[args ret]`. See [Function Guards](docs/function-schemas.md#function-guards) for more details. Fixes [#764](https://github.com/metosin/malli/issues/764) and [#764](https://github.com/metosin/malli/issues/764).
Expand Down Expand Up @@ -561,14 +603,14 @@ No need to play with Compiler options or JVM properties to swap the default regi

;; look ma, just works
(mr/set-default-registry!
(mr/composite-registry
(m/default-schemas)
(mu/schemas)))
(mr/composite-registry
(m/default-schemas)
(mu/schemas)))

(mg/generate
[:merge
[:map [:x :int]]
[:map [:y :int]]])
[:merge
[:map [:x :int]]
[:map [:y :int]]])
; => {:x 0, :y 92}
```

Expand Down
60 changes: 52 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ So, we decided to spin out our own library, which would do all the things we fee

Malli requires Clojure 1.11.

Malli is tested with the LTS releases Java 8, 11, 17 and 21.

## Quickstart

```clojure
Expand Down Expand Up @@ -128,6 +130,7 @@ Examples:

;; a function schema of :int -> :int
[:=> [:cat :int] :int]
[:-> :int :int]
```

Usage:
Expand Down Expand Up @@ -175,6 +178,8 @@ Alternative map-syntax, similar to [cljfx](https://github.com/cljfx/cljfx):
{:type :=>
:input {:type :cat, :children [{:type :int}]}
:output :int}
{:type :->
:children [{:type :int} {:type :int}]}
```

Usage:
Expand Down Expand Up @@ -393,7 +398,7 @@ You can use `:sequential` to describe homogeneous sequential Clojure collections
;; => false
```

Malli also supports sequence regexes (also called sequence expresions) like [Seqexp](https://github.com/cgrand/seqexp) and Spec.
Malli also supports sequence regexes (also called sequence expressions) like [Seqexp](https://github.com/cgrand/seqexp) and Spec.
The supported operators are `:cat` & `:catn` for concatenation / sequencing

```clojure
Expand Down Expand Up @@ -454,7 +459,7 @@ while `:cat` and `:alt` just use numeric indices for paths:
;; {:path [0 1 1], :in [3], :schema boolean?, :value 11})}
```

As all these examples show, the sequence experssion (seqex) operators take any non-seqex child schema to
As all these examples show, the sequence expression (seqex) operators take any non-seqex child schema to
mean a sequence of one element that matches that schema. To force that behaviour for
a seqex child `:schema` can be used:

Expand Down Expand Up @@ -1136,6 +1141,49 @@ Going crazy:
; => {:x 24}
```

`:and` accumulates the transformed value left-to-right.

```clojure
(m/decode
[:and
[:string {:decode/string '{:enter #(str "1_" %), :leave #(str % "_2")}}]
[:string {:decode/string '{:enter #(str "3_" %), :leave #(str % "_4")}}]]
"kerran" mt/string-transformer)
;; => "3_1_kerran_2_4"
```

`:or` transforms using the first successful schema, left-to-right.

```clojure
(m/decode
[:or
[:string {:decode/string '{:enter #(str "1_" %), :leave #(str % "_2")}}]
[:string {:decode/string '{:enter #(str "3_" %), :leave #(str % "_4")}}]]
"kerran" mt/string-transformer)
;; => "1_kerran_2"

(m/decode
[:or
:map
[:string {:decode/string '{:enter #(str "3_" %), :leave #(str % "_4")}}]]
"kerran" mt/string-transformer)
;; => "3_kerran_4"
```

Proxy schemas like `:merge` and `:union` transform as if `m/deref`ed.

```clojure
(m/decode
[:merge
[:map [:name [:string {:default "kikka"}]] ]
[:map [:description {:optional true} [:string {:default "kikka"}]]]]
{}
{:registry (merge (mu/schemas) (m/default-schemas))}
(mt/default-value-transformer {::mt/add-optional-keys true}))
;; => {:name "kikka"
;; :description "kikka"}
```

## To and from JSON

The `m/encode` and `m/decode` functions work on clojure data. To go
Expand Down Expand Up @@ -3251,7 +3299,7 @@ Sequence/regex-schemas: `:+`, `:*`, `:?`, `:repeat`, `:cat`, `:alt`, `:catn`, `:

### `malli.core/base-schemas`

Contains `:and`, `:or`, `:orn`, `:not`, `:map`, `:map-of`, `:vector`, `:sequential`, `:set`, `:enum`, `:maybe`, `:tuple`, `:multi`, `:re`, `:fn`, `:ref`, `:=>`, `:function` and `:schema`.
Contains `:and`, `:or`, `:orn`, `:not`, `:map`, `:map-of`, `:vector`, `:sequential`, `:set`, `:enum`, `:maybe`, `:tuple`, `:multi`, `:re`, `:fn`, `:ref`, `:=>`, `:->`, `:function` and `:schema`.

### `malli.util/schemas`

Expand Down Expand Up @@ -3399,7 +3447,7 @@ You can call describe on a schema to get its description in english:
- Schema https://github.com/plumatic/schema
- Clojure.spec https://clojure.org/guides/spec
- Spell-spec https://github.com/bhauman/spell-spec
- JSON Schema https://json-schema.org/understanding-json-schema/index.html
- JSON Schema https://json-schema.org/understanding-json-schema
- Spec-provider: https://github.com/stathissideris/spec-provider
- F# Type Providers: https://docs.microsoft.com/en-us/dotnet/fsharp/tutorials/type-providers/
- Minimallist https://github.com/green-coder/minimallist
Expand All @@ -3424,10 +3472,6 @@ The API layers and stability:
* **experimental**: stuff in `malli.experimental` ns, code might change be moved under a separate support library, but you can always copy the old implementation to your project, so ok to use.
* **private API**: private vars and `malli.impl` namespaces, all bets are off.

## Supported Java versions

Malli aims to support the LTS releases Java 8 and 11 and the latest Java release, Java 15.

# Development

Malli is open for contributions. Before contributing with a PR, please open an issue for it.
Expand Down
22 changes: 11 additions & 11 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.11.2"}
:deps {org.clojure/clojure {:mvn/version "1.11.3"}
borkdude/dynaload {:mvn/version "0.3.5"}
borkdude/edamame {:mvn/version "1.4.25"}
org.clojure/test.check {:mvn/version "1.1.1"}
Expand All @@ -8,26 +8,26 @@
mvxcvi/arrangement {:mvn/version "2.1.0"}}
:aliases {:test {:extra-paths ["test"]
:extra-deps {com.gfredericks/test.chuck {:mvn/version "0.2.14"}
lambdaisland/kaocha {:mvn/version "1.87.1366"}
lambdaisland/kaocha {:mvn/version "1.91.1392"}
lambdaisland/kaocha-cljs {:mvn/version "1.5.154"}
org.babashka/sci {:mvn/version "0.8.41"}
lambdaisland/kaocha-junit-xml {:mvn/version "1.17.101"}
metosin/spec-tools {:mvn/version "0.10.6"}
metosin/spec-tools {:mvn/version "0.10.7"}
spec-provider/spec-provider {:mvn/version "0.4.14"}
metosin/schema-tools {:mvn/version "0.13.1"}
metosin/jsonista {:mvn/version "0.3.8"}
metosin/jsonista {:mvn/version "0.3.9"}
prismatic/schema {:mvn/version "1.4.1"}
minimallist/minimallist {:mvn/version "0.0.10"}
net.cgrand/seqexp {:mvn/version "0.6.2"}
djblue/portal {:mvn/version "0.53.0"}
djblue/portal {:mvn/version "0.56.0"}
meta-merge/meta-merge {:mvn/version "1.0.0"}
expound/expound {:mvn/version "0.9.0"}
lambdaisland/deep-diff {:mvn/version "0.0-47"}
com.bhauman/spell-spec {:mvn/version "0.1.2"}
org.clojure/spec-alpha2 {:git/url "https://github.com/clojure/spec-alpha2.git"
:sha "4cbfa677c4cd66339f18e1c122222c05c69e0d8e"}}}
:sci {:extra-deps {org.babashka/sci {:mvn/version "0.8.41"}}}
:cherry {:extra-deps {io.github.squint-cljs/cherry {:git/sha "0c4e0d1de534a4cf910ed7079638dbcfec8ec8b7"}}}
:cherry {:extra-deps {io.github.squint-cljs/cherry {:git/sha "437b7398efe9a0fc60ee8a27d7bae5eb9b14df98"}}}
:test-sci {:extra-paths ["test-sci"]
:main-opts ["-m" "cljs-test-runner.main" "-d" "test-sci" "-d" "test"]}
:test-cherry {:extra-paths ["test-cherry"]
Expand All @@ -37,7 +37,7 @@
com.widdindustries/cljs.java-time {:mvn/version "0.1.20"}}
:extra-paths ["test" "cljs-test-runner-out/gen"]
:main-opts ["-m" "cljs-test-runner.main" "-d" "test"]}
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.10.0" :git/sha "3a2c484"}}
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.10.4" :git/sha "31388ff"}}
:ns-default build}
:jmh {:paths ["target/uber.jar" "classes"]
:deps {jmh-clojure/jmh-clojure {:mvn/version "0.4.1"}
Expand All @@ -49,7 +49,7 @@
org.clojure/tools.namespace #_:clj-kondo/ignore {:mvn/version "RELEASE"}}}

:shadow {:extra-paths ["app"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.28.2"}
:extra-deps {thheller/shadow-cljs {:mvn/version "2.28.10"}
binaryage/devtools {:mvn/version "1.0.7"}}}
:slow {:extra-deps {io.dominic/slow-namespace-clj
{:git/url "https://git.sr.ht/~severeoverfl0w/slow-namespace-clj"
Expand All @@ -68,12 +68,12 @@
:main-opts ["-m" "deps-deploy.deps-deploy" "install"
"malli.jar"]}
:graalvm {:extra-paths ["graal-test/src"]
:extra-deps {org.clojure/clojure {:mvn/version "1.11.2"}
:extra-deps {org.clojure/clojure {:mvn/version "1.11.3"}
org.babashka/sci {:mvn/version "0.8.41"}}}
:perf {:extra-paths ["perf"]
:extra-deps {criterium/criterium {:mvn/version "0.4.6"}
org.clojure/clojure {:mvn/version "1.11.2"}
com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.2.0"}}
org.clojure/clojure {:mvn/version "1.11.3"}
com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.2.2"}}
:jvm-opts ["-server"
"-Xmx4096m"
"-Dclojure.compiler.direct-linking=true"]}}}
Loading

0 comments on commit da7cbb0

Please sign in to comment.