malli

https://github.com/metosin/malli :malli:
Daniel Miladinov 2021-01-21T19:06:00.003Z

Hi everyone, long-time listener, first-time caller here. I’m still kind of new to malli and I’m trying to develop a spec to validate a vector of strings, but some of the strings have different validations than the others. Looking at the https://github.com/metosin/malli#sequence-schemas, it seemed to me that I should use a sequence schema with something like [:cat …].

Daniel Miladinov 2021-01-21T19:07:08.003900Z

But I’m having a problem. According to the README, I should be able to do this:

(m/validate [:cat string? int?] ["foo" 0]) ; => true
But in my repl, I get this:
(require '[malli.core :as m])
=> nil
(m/validate [:cat string? int?] ["foo" 0])
Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:79).
:malli.core/invalid-schema {:schema :cat}

Daniel Miladinov 2021-01-21T19:23:46.004Z

The project I’m working in has reitit 0.5.11 as a direct dependency, which appears to pull in malli 0.2.1 as a transitive dependency.

ikitommi 2021-01-21T20:02:22.004200Z

if you use deps, you can take a dependency to the latest commit of Malli, which has the sequence schemas. Will try to ship a Big 0.3.0 out within few weeks with those officially in.

👍 1
ikitommi 2021-01-21T20:03:14.004400Z

There is also [:tuple string? int?] for fixed length vectors with schema for each element

❤️ 1
Daniel Miladinov 2021-01-21T20:03:35.004700Z

Thank you!!!

Daniel Miladinov 2021-01-21T20:03:50.004900Z

That will serve my purposes in the meantime