Fork me on GitHub
#clojure-spec
<
2018-07-17
>
markt11:07:48

Think I asked in the wrong channel... too many channels https://clojurians.slack.com/archives/CB19ETU0N/p1531736138000105

mpenet11:07:42

not really

mpenet11:07:20

maybe some external lib does, but not spec itself afaik

ikitommi12:07:26

@markt you were using schema-tools.core/select-schema? By design, Spec doesn't support closed keys. 3rd party?, there is at least spec-tools.core/select-spec for this

markt12:07:30

Ah thought that would be the case, it's a bit of a odd case we have. Cool thanks for the heads up, i'll have a look at spec-tools :thumbsup:

ikitommi12:07:24

I think it’s the odd case not to strip out extra data at the borders.

markt12:07:37

Interesting, so you would prefer to have a function only return what the spec dictates?

markt14:07:49

Just noticed your the author of the library! Thanks for writing the library 😄

ikitommi15:07:37

not at function level, but at system boundaries: Reading JSON sent by a (potentially rogue) third party, or when writing to a (document) database. Not removing extra keys is a security risk, stripping keys manually is both error prone & extra work.

markt12:07:52

absolutely agree, and thanks for all the help

gklijs18:07:15

It's not that hard using specs to implement losing the rest. I rather have a bit of code than a dependency. That's the road I took, also added the option to have default values for keys, to keep specs backwards compatible.