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

defroutes w/ validations nil param fix #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RyanBertrand
Copy link

I was getting errors while using defroute with validations.

My vector route looked like:

(defroute ["/patient/:patient-id" :patient-id #"pat_[A-Za-z0-9]{16}"]
            {:keys [patient-id] :as params}
            (do))

The error printed to the JS console was:

re-matches must match against a string

It seems that calling re-matches when the value pulled from params is nil throws an error in invalid-params fn.

This pr adds an additional check to see if the param value is non-nil before trying to validate it via regex. If it is nil, then it is essentially invalid as it doesn't match the route.

Thanks for the great library!

It seems that calling re-matches when the value pulled from params is nil throws an error.
@borkdude
Copy link
Contributor

@RyanBertrand

Any reason you're not using nil??
Please add a unit test for this change.

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

Successfully merging this pull request may close these issues.

2 participants