Data::Validate::Sanctions - Validate a name against sanctions lists
# as exported function
use Data::Validate::Sanctions qw/is_sanctioned get_sanction_file set_sanction_file/;
set_sanction_file('/var/storage/sanction.csv');
print 'BAD' if is_sanctioned($first_name, $last_name);
# as OO
use Data::Validate::Sanctions;
#You can also set sanction_file in the new method.
my $validator = Data::Validate::Sanctions->new(sanction_file => '/var/storage/sanction.csv');
print 'BAD' if $validator->is_sanctioned("$last_name $first_name");
Data::Validate::Sanctions is a simple validitor to validate a name against sanctions lists.
The list is from the following sources:
- https://www.treasury.gov/ofac/downloads/sdn_xml.zip
- https://www.treasury.gov/ofac/downloads/consolidated/consolidated.xml
- https://ofsistorage.blob.core.windows.net/publishlive/ConList.csv
- https://webgate.ec.europa.eu/fsd/fsf/public/files/xmlFullSanctionsList_1_1/content?token=$eu_token
run update_sanctions_csv to update the bundled csv.
The path of list can be set by function "set_sanction_file" or by method "new". If not set, then environment variable $ENV{SANCTION_FILE} will be checked, at last the default file in this package will be used.
Note that a positive result means marked as prohibited
and negative result means innocent
.
- Client information can be passed in two ways:
a.) a hash-ref containing any of these fields:
first_name
(required),last_name
(required),date_of_birth
,place_of_birth
,residence
,citizen
,nationality
,postal_code
,national_id
,passport_no
. Example:get_sanctioned_info({first_name => 'Alex', last_name => 'Xela', date_of_birth => '..', residence => 'fr', citizen => 'Iran');
b.) three scalar arguments (to keep compliant with the old API):
Example: get_sanctioned_info($client->first_name, $client->last_name, $client->date_of_birth);
-
first_name
andlast_name
are treated together as thefull_name
. Thefull_name
is then cleaned by removing non-alphabets (if any) Example:Ahmad Sheikh
becomesAHMAD SHEIKH
-
The above procedure is applied when a sanctioned individual's name is used Example:
ABDUL-QADER Ahmad Sheik
becomesABDUL QADER AHMAD SHEIKH
-
Name matching takes place, based on the following four scenarios: a.) Exact name: If the client is
Ahmad Sheikh
and the sanctioned individual isAhmad Sheikh
, it is a positive match. Even if the names were reversed, the match would stil be positive, as it looks for exact wording and regardless of order. b.) Partial exact match (I): If the client isAhmad Sheikh
and the sanctioned individual isAbdul Qader Ahmad Sheikh
, then it is also a positive match. This is because the client's nameAhmad Sheikh
is a substring ofAbdul Qader Ahmad Sheikh
. c.) Partial exact match (II): If the client isAbdul Qader Ahmad Sheikh
and the sanctioned individual isAhmad Sheikh
, then it is also a positive match. This is because, as mentioned above, it is a substring and also because we take the shortest name into consideration first and compare with the longer name.
NOTE: As long as there are two or more matches, the result will always be a positive match due to name similarity. If the shortest name has only one token and there is a match, then it is also a positive result.
-
If a
date_of_birth
value is passed, it is compared to the list of date_of_birth in the sanction lists (if a value is found), based on epoch value and the sanctioned individual's name. -
Scenarios to consider when date_of_birth is taken into consideration: a.)
name matches and no date_of_birth value found in sanctions list
: This returns a positive result b.)name matches and date_of_birth matches
: This returns a positive result c.)name matches but date_of_birth does not match from all given values
: This returns a negative result d.)name matches but no date_of_birth value is passed
: This returns a positive result
is_sanctioned({first_name => '...', last_name => '...', date_of_birth => '...'});
is_sanctioned($last_name, $first_name);
is_sanctioned($first_name, $last_name);
is_sanctioned("$last_name $first_name");
when one string is passed, please be sure last_name is before first_name.
or you can pass first_name, last_name (last_name, first_name), we'll check both "$last_name $first_name" and "$first_name $last_name".
return list name for yes, 0 for no.
it will remove all non-alpha chars and compare with the list we have.
Create the object, and set sanction_file
my $validator = Data::Validate::Sanctions->new(sanction_file => '/var/storage/sanction.csv');
get sanction_file which is used by "is_sanctioned" (procedure-oriented)
set sanction_file which is used by "is_sanctioned" (procedure-oriented)
Binary.com [email protected]
Copyright 2014- Binary.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.