View Source Nip.Pppk (indonesian_id v1.0.0)

Functions for working with NIP PPPK (Pegawai Pemerintah dengan Perjanjian Kerja)

NIP PNS consists of 18 digits that divided into 4 parts:

  • 8 digits for birth date (YYYYMMDD)
  • 4 digits for TMT (Tanggal Mulai Tugas) (YYYY)
  • 1 digit that indicates the code for PPPK (2)
  • 1 digit for frequency (1-9)
  • 1 digit for sex code (1 for male and 2 for female)
  • 3 digits for serial number (001-999)

Summary

Functions

Parse NIP PPPK into a struct.

Validate NIP format.

Functions

parse(nip)

@spec parse(String.t()) :: {:ok, struct()} | {:error, String.t()}

Parse NIP PPPK into a struct.

This function returns {:ok, %Nip.Pppk{}} if the NIP is valid, otherwise {:error, reason}.

Examples

iex> Nip.Pppk.parse("200012312024211001")
{:ok,
%Nip.Pppk{
  nip: "200012312024211001",
  birth_date: ~D[2000-12-31],
  tmt_date: ~D[2024-01-01],
  frequency: 1,
  sex: "M",
  serial_number: "001"
}}

validate_format(nip)

@spec validate_format(String.t()) :: {:ok | :error, String.t()}

Validate NIP format.

This function returns {:ok, nip} if the NIP is valid, otherwise {:error, reason}.

Examples

iex> Nip.Pppk.validate_format("200012312024211001")
{:ok, "200012312024211001"}