Business::SWIFT - Validate SWIFT/BIC Bank identifiers.


Business-SWIFT documentation Contained in the Business-SWIFT distribution.

Index


Code Index:

NAME

Top

Business::SWIFT - Validate SWIFT/BIC Bank identifiers.

VERSION

Top

Version 0.01

SYNOPSIS

Top

This module implements the SWIFT BIC format validation.

It checks if the given SWIFT BIC code is well-formed according to the ISO 9362 Specification. It does not check if the code is a valid actual bank code.



    use Business::SWIFT;

    if ( Business::SWIFT->validateBIC('DEUTDEFF') ){
        .. do stuff ..
    }




Based on the following specification: http://en.wikipedia.org/wiki/ISO_9362

FUNCTIONS

Top

validateBIC

Returns a true value if the given BIC code is correct. False otherwise.

Code letters have to be uppercase.

This is a class method.

Usage example:

    if ( Business::SWIFT->validateBIC('DEUTDEFF') ){
       .. do stuff ..
    }




AUTHOR

Top

Jerome Eteve <jerome at eteve.net>

BUGS AND LIMITATIONS

Top

Please report any bugs or feature requests to bug-business-swift at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Business-SWIFT. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Business::SWIFT

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Business-SWIFT

* CPAN Ratings

http://cpanratings.perl.org/d/Business-SWIFT

* RT: CPAN's request tracker

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

* Search CPAN

http://search.cpan.org/dist/Business-SWIFT

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Business-SWIFT documentation Contained in the Business-SWIFT distribution.
package Business::SWIFT;

use warnings;
use strict;

use Locales ;

our $VERSION = '0.02';

sub validateBIC{
    my ( $class , $candidate ) = @_ ;
    
    my $candLength = length($candidate) ;
    if( ( 8 != $candLength ) && ( 11 != $candLength ) ){
        return 0;
    }
    
    my ( $bankCode , $countryCode ,
         $locationCode , $branchCode ) = ( $candidate =~ /^([A-Z]{4})([A-Z]{2})([A-Z0-9]{2})([A-Z0-9]{3})?/  );
    if( ! $bankCode ){
        return 0;
    }
    
    my $en = Locales->new( "en" );
    
    if ( ! $en->get_territory_from_code( $countryCode ) ){
        return 0;
    }
    
    if ( ! $locationCode ){
        return 0;
    }
    
    if ( ( $candLength == 11 ) && ( ! $branchCode ) ){
        return 0;
    }
    
    ## All is correct
    return 1;
}


1; # End of Business::SWIFT