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 …]
.
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}
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.
There is also [:tuple string? int?]
for fixed length vectors with schema for each element
Thank you!!!
That will serve my purposes in the meantime