threatgrid / flanders

Define data types for CTIM
Eclipse Public License 1.0
1 stars 6 forks source link

optionalize-all on any-keyword type makes any keyword forbidden #20

Closed gbuisson closed 6 years ago

gbuisson commented 6 years ago

https://github.com/threatgrid/flanders/blob/master/src/flanders/utils.cljc#L73

An interesting side effect of optionalize-all is that it makes schemas like:

(schema.core/defschema foo {(s/optional-key schema.core/Keyword) schema.core/Str})

this fails to validate any data, any keyword is then forbidden:

ctia.main=> (schema.core/defschema foo {(schema.core/optional-key schema.core/Keyword) schema.core/Str})
#'ctia.main/foo
ctia.main=> (schema.core/validate foo {:boom "bar"})

ExceptionInfo Value does not match schema: {:boom disallowed-key}  schema.core/validator/fn--2177 (core.clj:155)
hshahman commented 6 years ago

No QA required.