area icon indicating copy to clipboard operation
area copied to clipboard

Create separate methods for processing area codes versus zip codes

Open monfresh opened this issue 11 years ago • 1 comments

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?

monfresh avatar May 13 '13 07:05 monfresh

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.

jgv avatar Jul 03 '13 20:07 jgv