Multi-national validation?!

ferreira on 2005-08-11T02:39:16

Think about it. You have an application which holds addresses in various parts of the world and want to make a minimum sanity check for post codes. Then you write:

  use Business::PostCode;
  # get adresses
  for (@addresses) {
     if (postcode_ok($_->country, $_->postcode)) {
       # ok, go on
     } else {
       # not ok, reject
     }
  }
and that's it!

Business::PostCode would integrate national modules like Business::BR::PostCode, Business::PT::PostCode, etc. to provide a worldly great benefit. That was a suggestion raised by _brian_d_foy after cog triggered a discussion on modules@perl.org about modules for validation. Was something like this attempted before? It seems to me Business::PostCode would be trivial provided Business::<Country>::PostCode modules with a common protocol.

What about other ideas for border-crossing Perl modules? Passport checking?


Call me cary...but...

jk2addict on 2005-08-11T11:29:00

Would it be better if they were Business::PostCode::BR, Business::PostCode::PT?

Re: Call me cary...but...

ferreira on 2005-08-12T00:20:06

Yep, from an international point of view. But from a country-wise perspective, Business::<Country>:: would be the easy way to find out the available validation modules of a certain country. International modules (like Business::PostCode) would cross borders by requiring Business::BR::PostCode, Business::PT::PostCode as needed. My guess is that using a bunch of modules within a certain country will be more common than multi-national modules. That's the rationale for making it obvious within the Business::<Country> namespace and possible across nations.

Re: Call me cary...but...

jk2addict on 2005-08-12T12:44:58

Huh, never thought there would be a need for multiple postcodes in a single country; or just that we're talking all validators, not just post code. Makes perfect sense now. :-)