jgv / area

Perform a variety of conversions between places and area codes or zip codes.
http://jonathanvingiano.com/area
MIT License
176 stars 58 forks source link

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

Open monfresh opened 11 years ago

monfresh commented 11 years ago

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 commented 11 years ago

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.