Skip to content

fix(isVAT): accept the 16-digit Indonesian NPWP - #2977

Open
FSA-G wants to merge 1 commit into
validatorjs:masterfrom
FSA-G:fix-isvat-id-npwp
Open

FSA-G wants to merge 1 commit into
validatorjs:masterfrom
FSA-G:fix-isvat-id-npwp

Conversation

@FSA-G

@FSA-G FSA-G commented Nov 29, 2026

Copy link
Copy Markdown

isVAT(str, 'ID') only accepts the old 15-digit NPWP. Since PMK 112/PMK.03/2022 the NPWP has 16 digits:

  • resident individuals use their NIK (16 digits) as their NPWP
  • other taxpayers (companies, government agencies, non-residents) use the old 15-digit number with a 0 in front

The 16-digit format is the one used in the tax system now, so valid numbers are rejected today:

isVAT('013121660091000', 'ID')  // true  (old 15-digit format)
isVAT('0013121660091000', 'ID') // false (same number, new 16-digit format)

This PR accepts 15 or 16 digits (with the optional ID prefix, as before).

It also escapes the dots in the formatted pattern (12.345.678.9-012.345). They were unescaped, so any character matched, e.g. isVAT('12a345b678c9-012d345', 'ID') returned true. The formatted 15-digit form is otherwise unchanged. The 16-digit number has no official punctuated form, so I only accept it as plain digits.

References:

Tests: added valid 16-digit numbers (with and without ID, and a NIK-style number) and invalid ones (17 digits, letters in place of the dots, a 16-digit number in the formatted pattern). The new valid cases fail without the change. npm test passes (323 passing, 100% statements).

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable): not needed, the ID country code is already listed
  • Tests written (where applicable)
  • References provided in PR (where applicable)

Since PMK 112/PMK.03/2022 the NPWP has 16 digits: the NIK for resident
individuals, and the old 15-digit number with a leading 0 for other
taxpayers. Also escape the dots in the formatted 15-digit pattern, which
matched any character.
@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ff3424) to head (a69c89b).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2977   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2599           
  Branches       658       658           
=========================================
  Hits          2599      2599           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant