Fork me on GitHub
#schema
<
2022-01-14
>
Al Z. Heymer15:01:16

Why is that valid?

(s/validate {:a [s/Str] s/Keyword s/Str} {:a []})
I would expect, that it would fail due to {s/Keyword s/Str}

dpsutton15:01:08

I think this can help shed some light:

(s/validate {s/Any s/Str s/Keyword s/Str} {:a []})
Execution error at schema.core/find-extra-keys-schema (core.clj:782).
More than one non-optional/required key schemata: [Any Keyword]
Schema is aware that both of these are generic and there’s no clear precedence. In yours, both :a and s/Keyword match, but it seems that Schema is aware of which one should take precedence. It doesn’t seem to stack them and goes with the most specific matcher

☝️ 1
👍 1