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

spec coercion to int #446

Open
jeroenvanwijgerden opened this issue Aug 13, 2020 · 1 comment
Open

spec coercion to int #446

jeroenvanwijgerden opened this issue Aug 13, 2020 · 1 comment

Comments

@jeroenvanwijgerden
Copy link

Library Version(s)

2.0.0-alpha31

Problem

(s/def ::version (s/and int? #{1 2}))

(GET "/test/:v" request
      :path-params [v :- ::version]
      (r/ok v))

when requesting GET /test/1 results in

{:problems
    [{:message "Validation error",
      :details
      {:path ["v"],
       :pred [1 2],
       :val "1",
       :via ["spec$60151/v"],
       :in ["v"],
       :phrase.alpha/mappings {:x0 1, :x1 2, :x2 ["x1" "x0"]},
       :phrase.alpha/via []}}]}

However

(s/def ::version #{1 2})

(GET "/test/:v" request
      :path-params [v :- (s/and int? ::version)]
      (r/ok v))

when requesting GET /test/1 does give me the expected response body of 1.

@thomaswhitcomb
Copy link
Contributor

@jeroenvanwijgerden what is the "s" namespace?

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