You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered: