| Business-ID-NIK documentation | view source | Contained in the Business-ID-NIK distribution. |
Business::ID::NIK - Validate Indonesian citizenship registration number (NIK)
version 0.03
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!";
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.
Create a new Business::ID::NIK object.
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.
Return validation error of NIK, or undef if no error is found. See
validate().
Return formatted NIK, or undef if NIK is invalid.
Alias for normalize().
Return 6-digit province code + city/district + subdistrict component of NIK.
Return a DateTime object containing the date of birth component of the NIK, or undef if NIK is invalid.
Alias for day_of_birth()
Return gender ('M' for male and 'F' for female), or undef if NIK is invalid.
Return 4-digit serial component of NIK, or undef if NIK is invalid.
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.
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2011 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| Business-ID-NIK documentation | view source | Contained in the Business-ID-NIK distribution. |