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

Parameter coercion of booleans #150

Closed
khadiwala opened this issue May 2, 2016 · 1 comment
Closed

Parameter coercion of booleans #150

khadiwala opened this issue May 2, 2016 · 1 comment
Labels

Comments

@khadiwala
Copy link

I have a route like this

(defroutes app-routes
  (GET "/foo/:bar" [bar :<< Boolean/valueOf] "success"))

where I'm trying to coerce bar to a boolean. /foo/true is matched by this route, but /foo/false is not. What I'm guessing is happening is that because my coercion function is returning false, it is assumed to have failed. If I have that right, I think this is incorrect and only nil should be considered a failed match as indicated in the documentation here: https://github.com/weavejester/compojure/wiki/Destructuring-Syntax#parameter-coercion.

@weavejester
Copy link
Owner

Thanks for the report! I believe that's a bug. The problem is in on line 114 of core.clj, where and was used, instead of checking to see whether all the values were nil.

As an aside, however, Boolean/valueOf isn't a function, and so currently only works by happenstance. In Clojure static methods can't be treated the same as functions, because they're not objects.

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

No branches or pull requests

2 participants