Skip to content

Test data (fake)

  1. 3174081502956104
  2. 5321124709513217
  3. 3603145212584822
  4. 7102226209055152
  5. 3471126703912239

The same seed gives the same values in Go and TypeScript. For tests only.

Runs in your browser.

Every generator takes a 32-bit seed (uint32 in Go, an integer from 0 to 4,294,967,295 in TypeScript). The same seed and options return the same value in Go and TypeScript, so fixtures can be shared between a Go backend and a TypeScript frontend.

Go TypeScript Options
fake.NIK(seed, opts) await fake.nik(seed, opts?) region, birthDate, sex
fake.NPWP(seed) fake.npwp(seed)
fake.Phone(seed) fake.phone(seed)
fake.NIP(seed, opts) fake.nip(seed, opts?) birthDate, sex
fake.NISN(seed) fake.nisn(seed)
fake.Plate(seed, opts) fake.plate(seed, opts?) region (plate code such as B)
  • A NIK uses a real district code. region can pin it to a province (31), regency (31.71) or district (31.71.01). birthDate (YYYY-MM-DD) and sex (male or female) set the encoded date and the +40 day offset.
  • In TypeScript fake is only exported from nusaindex/fake, never from the root, so it cannot end up in a production bundle by accident. fake.nik is async because district data loads per province.
  • Go returns string for generators without options. TypeScript returns a Result for all of them, which fails with options for an invalid seed.

Changes to region data can change the NIK generated for a seed. Pin the NusaIndex version in tests that compare exact values.

options, date, region.

package main
import (
"fmt"
"github.com/haikalmumtaz233/nusaindex/fake"
)
func main() {
id, err := fake.NIK(7, fake.NIKOptions{Region: "31.71", BirthDate: "1990-05-17", Sex: fake.SexFemale})
if err == nil {
fmt.Println(id)
}
fmt.Println(fake.NPWP(3))
fmt.Println(fake.Phone(11))
fmt.Println(fake.NISN(7))
employee, err := fake.NIP(5, fake.NIPOptions{BirthDate: "1990-05-17", Sex: fake.SexFemale})
if err == nil {
fmt.Println(employee)
}
car, err := fake.Plate(7, fake.PlateOptions{Region: "B"})
if err == nil {
fmt.Println(car)
}
}
Output
3171035705900812
0315588931648000
+6283235644488
6299763315
199005172021112541
B 3739 J