Skip to content

Fix/ja jp postcode leading zero#1041

Open
hunhunyosshy wants to merge 2 commits into
FakerPHP:2.0from
hunhunyosshy:fix/ja-jp-postcode-leading-zero
Open

Fix/ja jp postcode leading zero#1041
hunhunyosshy wants to merge 2 commits into
FakerPHP:2.0from
hunhunyosshy:fix/ja-jp-postcode-leading-zero

Conversation

@hunhunyosshy

Copy link
Copy Markdown

What is the reason for this PR?

In Japan, some regions (notably Hokkaido) have postal codes starting with zero (e.g., 001-XXXX). The previous implementation used numberBetween(), which resulted in integers. When these were concatenated, leading zeros were lost (e.g., 001 became 1). This PR ensures leading zeros are preserved by using numerify().

  • A new feature
  • Fixed an issue (resolve leading zero issue in ja_JP postcode)

Author's checklist

Summary of changes

  • Changed postcode1() and postcode2() in Faker\Provider\ja_JP\Address to use numerify('###') and numerify('####') instead of numberBetween().
  • Updated PHPDoc @example tags to reflect string return values.
  • Added test/Faker/Provider/ja_JP/AddressTest.php to ensure the postcode format is correctly generated.

Review checklist

  • All checks have passed
  • Changes are added to the CHANGELOG.md
  • Changes are approved by maintainer

Changed postcode1() and postcode2() to use numerify() to preserve leading zeros, which are common in regions like Hokkaido.
@stale

stale Bot commented Mar 8, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the lifecycle/stale label Mar 8, 2026
@hunhunyosshy

Copy link
Copy Markdown
Author

Could you review and merge it if no problem?

@stale stale Bot removed the lifecycle/stale label Mar 8, 2026
@hunhunyosshy

Copy link
Copy Markdown
Author

@localheinz

Could you review and merge it if no problem?

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.

2 participants