NAME

Business::DK::Phonenumber - Danish telephone number validator/formatter

VERSION

This documentation describes version 0.01

SYNOPSIS

use Business::DK::Phonenumber qw(validate render);

        #Validation
        if (Business::DK::Phonenumber->validate($phonenumber)) { ... }
    
        #Default format
        print Business::DK::Phonenumber->render($phonenum);
        # +45 12 34 56 78
    
        #Brief human readable Danish phone number format
        print Business::DK::Phonenumber->render($phonenum, '%08d');
        # 12345678
    
        #Normal human readable Danish phonenumber format
        print Business::DK::Phonenumber->render($phonenum, '%02d %02d %02d %02d');
        # 12 34 56 78

        #Generation of a single random number
        Business::DK::Phonenumber->generate();
    
        #Generation of 100 random numbers, using another template
        Business::DK::Phonenumber->generate(100, '%02d %02d %02d %02d');

DESCRIPTION

This module offers functionality to validate, format and generate Danish phone numbers.

The validation can recognise telephone numbers is the following formats as Danish phone numbers.

In addition to validation the module offers generation of valid danish phone numbers. The purpose of using generated phone number is up to the user, but the original intent is generation of varied sets of test data.

If you want to use OOP please have a look at:

validate($phonenumber)

This subroutine takes a string and validated whether it is a Danish phone number.

Returns 1 (true) or 0 (false), depending on validity.

render($phonenumber, $template)

Returns a phonenumber rendered according to the template parameter or the default.

generate($template, $amount)

This subroutine takes a string representing a phone number template and generates the amount specified by second argument: amount. If no amount is specified only a single random phone number is returned.

The subroutine returns an array, no matter what amount is specified.

_generate($template)

This is the actual generating method used by generate.

It takes a single parameter, a string indicating the template for the formatting of the phone numbers to be generated.

It returns a single random number representing a Danish phone number formatted as outlined by the specified template.

validate_template

This method is used internally to validate template parameters. Please refer to Perl's sprintf for documentation.

DIAGNOSTICS

DEPENDENCIES

BUGS AND LIMITATIONS

No known bugs or limitations at this time.

TEST AND QUALITY

Class::Business::DK::Phonenumber
Data::FormValidator::Constraints::Business::DK::Phonenumber BUG REPORTING

Please report issues via CPAN RT:

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Business-DK-Phonenumber

or by sending mail to

bug-Business-DK-Phonenumber@rt.cpan.org

MOTIVATION

I have been working in Telco for a long time. So validation and formatting of telephone numbers is something I have seen at lot of. This module is an attempt to sort of consolidate the numerous different regular expression solutions I have seen scathered over large code bases.

AUTHOR

Jonas B. Nielsen, (jonasbn) - `<jonasbn@cpan.org>'

COPYRIGHT

Business-DK-Phonenumber is (C) by Jonas B. Nielsen, (jonasbn) 2008-2009

LICENSE

Business-DK-Phonenumber is released under the artistic license

The distribution is licensed under the Artistic License, as specified by the Artistic file in the standard perl distribution (http://www.perl.com/language/misc/Artistic.html).