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

Searching for a 6-digit zip code should result in a bad request #48

Closed
anselmbradford opened this issue Jun 27, 2013 · 3 comments
Closed
Labels

Comments

@anselmbradford
Copy link
Member

Searching for a 6-digit zip code should result in a bad request in the same way that searching for a 7-digit zip code returns a bad request

e.g.
http://ohanapi.herokuapp.com/api/search?location=123456

and

http://ohanapi.herokuapp.com/api/search?location=1234567

should return the same result

@anselmbradford
Copy link
Member Author

4-digit zip codes also should return a bad request? http://ohanapi.herokuapp.com/api/search?location=1236

@anselmbradford
Copy link
Member Author

Also, numerical-only address that starts with 4 zeros or more http://ohanapi.herokuapp.com/api/search?location=00000 and a 5-digit zip code that does not exist http://ohanapi.herokuapp.com/api/search?location=11111 or http://ohanapi.herokuapp.com/api/search?location=11111-1

@monfresh
Copy link
Member

We used to have a semi-complicated method that would check to see if the location parameter contained only digits. If that was the case, and if the number of digits was not exactly 5, it would be considered an invalid query. If it was exactly 5 digits, then it would use the "area" gem to look up the zip code and determine if it was an existing US zip code.

I opted for simplification and now let the geocoding service handle the input. If an input causes an error, I rescue the error and return a bad request status and an "Invalid ZIP code or address" message. If the input does not cause an error, but doesn't find anything, it returns an empty response.

A client that consumes the API can treat the "Invalid ZIP code or address" the same as "no results" when the location parameter is present. The front-end could then guide the user through steps that can yield results, such as suggesting to make sure they entered the right zip code or address, or to increase the radius (with an arrow pointing there or circling it), or to try searching by the predefined categories once we have those in place.

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