Skip to content

feat: add chinese_phone_number tag for Mainland-China mobile numbers - #100

Merged
bxcodec merged 1 commit into
go-faker:mainfrom
lutpul:feat/chinese-phone-number
Sep 13, 2026
Merged

bxcodec merged 1 commit into
go-faker:mainfrom
lutpul:feat/chinese-phone-number

Conversation

@lutpul

@lutpul lutpul commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

What

Adds a new chinese_phone_number tag that generates Mainland-China mobile
numbers (11 digits, e.g. 13812345678).

Why

The current phone_number / e_164_phone_number tags only produce Western
style numbers. Chinese data sets currently only cover names.

How

  • Pick a real 3-digit operator prefix from a curated list of 56 allocated
    prefixes (China Mobile / Unicom / Telecom / Broadnet, incl. MVNO & IoT
    segments), then append 8 random digits.
  • Follows the existing pattern of the chinese_first_name-style tags:
    tag constant + PriorityTags + defaultTag + mapperTag registration,
    Phoner interface method, standalone ChinesePhoneNumber() helper and
    unit tests (interface method, standalone call, and struct-tag end-to-end).

Tests

go test -race ./... passes; new tests validate against ^1[3-9]\d{9}$
and prefix membership.

@lutpul
lutpul force-pushed the feat/chinese-phone-number branch from 029a674 to 1de3a11 Compare September 7, 2026 11:32
@lutpul
lutpul force-pushed the feat/chinese-phone-number branch from 1de3a11 to a73ebe7 Compare September 7, 2026 11:39
@bxcodec
bxcodec merged commit d9aca1f into go-faker:main Sep 13, 2026
2 checks passed
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.

3 participants