If we try to pass a non-keyword to clojure.spec/keys
or clojure.spec/keys**
on the named argument :opt
or :opt-un
we get an assertion error:
`
(spec/valid? (spec/keys :opt ['a 5]) {})
;1. Caused by java.lang.AssertionError
; Assert failed: all keys must be namespace-qualified keywords
; (every? (fn* [p1__13667#] (c/and (keyword? p113667#) (namespace
; p113667#))) (concat req-keys req-un-specs opt opt-un))
(spec/valid? (spec/keys :opt-un ['a 5]) {})
;1. Caused by java.lang.AssertionError
; Assert failed: all keys must be namespace-qualified keywords
; (every? (fn [p1__13667#] (c/and (keyword? p113667#) (namespace
; p113667#))) (concat req-keys req-un-specs opt opt-un))
`
But if we do the same for the named arguments :req
and :req-un
the arguments are silently ignored and the call to keys
returns a spec matching any map without any requirements:
(spec/valid? (spec/keys :req ['a 5]) {})
=> true
(spec/valid? (spec/keys :req-un ['a 5]) {})
=> true
(spec/valid? (spec/keys* :req ['a 5]) {})
=> true
(spec/valid? (spec/keys* :req-un ['a 5]) {})
=> true
An assertion should probably be thrown for the :req(-un)?
args too.