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

Create separate methods for processing area codes versus zip codes #11

Open
monfresh opened this issue May 13, 2013 · 1 comment
Open

Comments

@monfresh
Copy link

This might be an edge case, but I am using this gem to validate zip codes entered into a search field. I need to be able to make sure that "012" throws an error. However, since your to_region method treats a string length of 3 as an area code, "012".to_region is returning nil when I'm expecting an error.

I would create separate methods for processing area codes versus zip codes. And when checking zip codes, I wouldn't just check if the length is 5, I would check that the string is in the right format using this regex: /^\d{5}(-\d{4})?$/

Thoughts?

@jgv
Copy link
Owner

jgv commented Jul 3, 2013

Hey Moncef,

Sorry for the late response. I'm able to concentrate on this after being quite busy for the last few months. I like both of these suggestions. In the 1.0 version of Area they will both be included and there will be no methods that have the ability to operate on both zipcodes and area codes.

Please send any more suggestions my way and follow along on the dev branch.

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