Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json-transformer not working correctly with set-specs #257

Open
Wegi opened this issue Aug 27, 2021 · 1 comment
Open

json-transformer not working correctly with set-specs #257

Wegi opened this issue Aug 27, 2021 · 1 comment

Comments

@Wegi
Copy link

Wegi commented Aug 27, 2021

When using a set in a spec, the coercion with the json-transformer does not work correctly. Here is a minimal example:

(s/def ::hello #{:one :two :three})
(s/def ::test-set (s/keys :req-un [::hello]))

(st/coerce ::test-set
           (->>
             {:hello :one}
             (m/encode "application/json")
             (m/decode "application/json"))
           st/json-transformer)

;; => {:hello "one"}

Is it intended to provide the type hint manually as described in the custom coercion section (https://github.com/metosin/spec-tools/blob/master/docs/01_coercion.md)? If so, please close the issue again.

@ikitommi
Copy link
Member

there is no auto-resolution of set types, you need to have (s/and keyword? #{::one :two :three}) for spec-tools to know the type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants