Fork me on GitHub
#malli
<
2020-11-29
>
joshkh14:11:17

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 "[email protected]"]}

joshkh14:11:44

this validates, but fails on generation

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

eval202015:11:39

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

joshkh15:11:11

not sure how i missed that. thanks eval2020.

ikitommi15:11:28

I think there should be a built-in complement.

ikitommi15:11:37

doesn’t exist, but should.

ikitommi15:11:43

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

👍 9
ikitommi15:11:32

also has now the full clj-kondo integration !!

ikitommi15:11:25

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

ikitommi15:11:05

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?

ikitommi15:11:25

any ideas about clojure.test helpers for malli?

ikitommi15:11:51

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.

ikitommi15:11:29

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