Business::ID::NIK - Validate Indonesian citizenship registration number (NIK)


Business-ID-NIK documentation  | view source Contained in the Business-ID-NIK distribution.

Index


NAME

Top

Business::ID::NIK - Validate Indonesian citizenship registration number (NIK)

VERSION

Top

version 0.03

SYNOPSIS

Top

    use Business::ID::NIK;

    # OO-style

    my $nik = Business::ID::NIK->new($str);
    die "Invalid NIK!" unless $nik->validate;

    print $nik->area_code, "\n";
    print $nik->date_of_birth, "\n"; # also, dob()
    print $nik->gender, "\n"; # M for male, or F for female
    print $nik->serial, "\n";

    # procedural style

    validate_nik($str) or die "Invalid NIK!";

DESCRIPTION

Top

This module can be used to validate Indonesian citizenship registration number, Nomor Induk Kependudukan (NIK), or more popularly known as Nomor Kartu Tanda Penduduk (Nomor KTP), because NIK is displayed on the KTP (citizen identity card).

NIK is composed of 16 digits as follow:

 pp.DDSS.ddmmyy.ssss

pp.DDSS is a 6-digit area code where the NIK was registered (it used to be but nowadays not always [citation needed] composed as: pp 2-digit province code, DD 2-digit city/district [kota/kabupaten] code, SS 2-digit subdistrict [kecamatan] code), ddmmyy is date of birth of the citizen (dd will be added by 40 for female), ssss is 4-digit serial starting from 1.

METHODS

Top

new $str

Create a new Business::ID::NIK object.

validate()

Return true if NIK is valid, or false if otherwise. In the case of NIK being invalid, you can call the errstr() method to get a description of the error.

errstr()

Return validation error of NIK, or undef if no error is found. See validate().

normalize()

Return formatted NIK, or undef if NIK is invalid.

pretty()

Alias for normalize().

area_code()

Return 6-digit province code + city/district + subdistrict component of NIK.

date_of_birth()

Return a DateTime object containing the date of birth component of the NIK, or undef if NIK is invalid.

dob()

Alias for day_of_birth()

gender()

Return gender ('M' for male and 'F' for female), or undef if NIK is invalid.

serial()

Return 4-digit serial component of NIK, or undef if NIK is invalid.

FUNCTIONS

Top

validate_nik($string)

Return true if NIK is valid, or false if otherwise. If you want to know the error details, you need to use the OO version (see the errstr method).

Exported by default.

AUTHOR

Top

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

Top


Business-ID-NIK documentation  | view source Contained in the Business-ID-NIK distribution.