This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Hey all, I again need help understanding why I'm having this error, according to the documentation :*
is used for repetition, which works in the normal case (last 2 lines) but in a function schema it does not work as it should and tells me my input needs to be a map when it should be a vector of maps, what is the problem?
args:`[:cat [:* map?] :string]` can be interpreted infix as args:_[map?* string]_ for example `[{} {} {} "foo"]` would be valid args. i.e. args must be sequence beginning with any number of maps and ending with exactly one string value. it seems you intended args:`[:cat [:sequential map?] :string]` instead
The :cat
inside your function schema is the argument list. So right now your schema accepts variable argument count where last item is a string.
> it seems you intended args:`[:cat [:sequential map?] :string]` instead It seems like that, I must have misunderstood the documentation. I'll try this and see how it works.
Is it actually the correct solution? I think that the proposed schema cannot match (test-fn "string")
> accepts variable argument count So if I understand that correctly, a variable map argument count, so any number of maps and the last argument is a string.
This might be the schema (haven't checked) [:=> [:cat [:tuple [:cat [:* :map]] :string]] :any]
> Is it actually the correct solution?
In this case it should be since my input must have at least one map in a vector
(test-fn [{}] "")
is what I want to pass.
does the schema accept (test-fn [] "")
?
Anyways, to understand the function schema better imagine it like this [:=> args-schema return-schema]
So if I have something like [=> [:cat :string :int] :boolean]
and call it with (the-fn "foo" 3) then it checks if ["foo" 3]
conforms [:cat :string :int]
and then checks the return value with return-schema.