malli

https://github.com/metosin/malli :malli:
joshkh 2020-11-29T14:05:17.151400Z

noob question, but how can i validate/generate non-blank strings? with spec i would use (complement clojure.string/blank?) .

(m/validate [:map [:name [:and string? (complement clojure.string/blank?)]]] {:name ""})
Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:79).
:malli.core/invalid-schema {:schema #object[clojure.core$complement$fn__5669 0x394ebe0b "clojure.core$complement$fn__5669@394ebe0b"]}

joshkh 2020-11-29T14:39:44.151500Z

this validates, but fails on generation

(m/validate [:map [:name [:fn (complement clojure.string/blank?)]]] {:name "test"})

eval2020 2020-11-29T15:13:39.151700Z

@joshkh the README has [:string {:min 1}] as example.

joshkh 2020-11-29T15:18:11.151900Z

not sure how i missed that. thanks eval2020.

ikitommi 2020-11-29T15:35:28.152100Z

I think there should be a built-in complement.

ikitommi 2020-11-29T15:35:37.152300Z

doesn’t exist, but should.

ikitommi 2020-11-29T15:36:43.153500Z

merged into master the current status of function schemas, alpha, feedback welcome! the guide is here: https://github.com/metosin/malli#function-schemas

👍 3
ikitommi 2020-11-29T15:36:56.153700Z

and the PR https://github.com/metosin/malli/pull/306

ikitommi 2020-11-29T15:37:32.154600Z

also has now the full :clj-kondo: integration !!

ikitommi 2020-11-29T15:38:25.155500Z

will make a separate PR of the optional plumatic-style helpers.

ikitommi 2020-11-29T15:40:05.156800Z

there are now var instrumentation helpers atm, only shipped use case is the clj-kondo type checker integration. Any ideas what would be a good api to instrument functions in dev to run the input & output checks?

ikitommi 2020-11-29T15:40:25.157300Z

any ideas about clojure.test helpers for malli?

ikitommi 2020-11-29T15:41:51.158800Z

dev-time tooling has not been the goal for malli (as it’s the primary goal for spec already), but happy to add things to that direction too.

ikitommi 2020-11-29T15:42:29.159200Z

with spec, have used https://github.com/jeaye/orchestra, I guess like everyone else 🙂