Fork me on GitHub
Daniel Miladinov19:01:00

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, it seemed to me that I should use a sequence schema with something like [:cat …].

Daniel Miladinov19:01:08

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 Miladinov19:01:46

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.


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.

👍 3

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

❤️ 3
Daniel Miladinov20:01:50

That will serve my purposes in the meantime