Skip to content

feat(locale): add Welsh (cy) postcode definitions#3851

Draft
IestynGage wants to merge 2 commits into
faker-js:nextfrom
IestynGage:next
Draft

feat(locale): add Welsh (cy) postcode definitions#3851
IestynGage wants to merge 2 commits into
faker-js:nextfrom
IestynGage:next

Conversation

@IestynGage
Copy link
Copy Markdown
Contributor

Based on the en_GB postcode definitions with a prefix as recommened by @matthewmayer in #3850 (comment)

@IestynGage IestynGage requested a review from a team as a code owner May 19, 2026 20:29
@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2026

Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1c4037a
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a0f892f25290e00079a7c12
😎 Deploy Preview https://deploy-preview-3851.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

export default [
'{{location.postcode_prefix}}# #??',
'{{location.postcode_prefix}}## #??',
];
Copy link
Copy Markdown
Contributor Author

@IestynGage IestynGage May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The en_GB is just export default ['??# #??', '??## #??']; I suppose you can also add a similiar prefix to en_GB as well. But the postcodes for England, NI, Scotland, Wales, crown dependecies and other special postcodes.

Copy link
Copy Markdown
Member

@ST-DDT ST-DDT May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.91%. Comparing base (e72fd7c) to head (c5759f0).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3851   +/-   ##
=======================================
  Coverage   98.91%   98.91%           
=======================================
  Files         905      905           
  Lines        3146     3146           
  Branches      581      581           
=======================================
  Hits         3112     3112           
  Misses         30       30           
  Partials        4        4           
Files with missing lines Coverage Δ
src/locales/cy/location/index.ts 100.00% <ø> (ø)
🚀 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.

Based on the `en_GB` postcode definitions with prefix as recommened by @matthewmayer.
@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: locale Permutes locale definitions m: location Something is referring to the location module labels May 19, 2026
@ST-DDT ST-DDT added this to the v10.x milestone May 19, 2026
Copy link
Copy Markdown
Member

@ST-DDT ST-DDT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to test your changes and verify that they return the expected results ⚠️

fakerCY.location.zipCode() // "{{location.postcode_prefix}}76 2MM"

Currently, the zipcode implementation does not support fake patterns (for default patterns).

This is planned for #3233 / #3176

Until then, you have to cross-product them yourself.

@IestynGage
Copy link
Copy Markdown
Contributor Author

IestynGage commented May 21, 2026

Please make sure to test your changes and verify that they return the expected results ⚠️

fakerCY.location.zipCode() // "{{location.postcode_prefix}}76 2MM"

Currently, the zipcode implementation does not support fake patterns (for default patterns).

This is planned for #3233 / #3176

Until then, you have to cross-product them yourself.

Oof that's embarrising 🤦 Just a heads up it will be away for a while before I can come back to this :)

@ST-DDT what do you mean by 'cross-product this myself?' Is it that:

  • Or do you mean I have to do it by "hand", as in change the content to 'CF# #??', 'CF## #??', etc and remove postcode_prefix?
  • update /src/definitions/location.ts?

I pushed a WIP commit of doing the latter, it seems to work. WIP as I would like to update some tests check that the other locales work as well and add documentation.

Also whats the easiest way to run faker locally? via testing or starting pnpm run docs:dev and then using the browser console?

@matthewmayer
Copy link
Copy Markdown
Contributor

Yes, do it by hand like

['CF# #??', 'CF## #??', 'CH# #??', 'CH## #??'...]

@matthewmayer
Copy link
Copy Markdown
Contributor

In the long run we would like to move to fake patterns and drop use of replaceSymbols completely, but that will potentially be a breaking change and impacts many locales, so the "by hand" trick is the easiest for now.

@ST-DDT
Copy link
Copy Markdown
Member

ST-DDT commented May 22, 2026

Also whats the easiest way to run faker locally? via testing or starting pnpm run docs:dev and then using the browser console?

There are 4 ways. In descending order of my personal preference.

  • pnpm tsx my-test.ts (easy to repeat and debug, looking into complex values may require JSON.stringify, no need to switch windows)
  • pnpm run docs:dev and then via browser console (easy to look into array/complex values , you may need to run it/generate:apidocs repeatedly)
  • clone and use the playground or create your own (you may need to build/install repeatedly)
  • write a (temporary) test, (vitest may add noise to your logs or run more tests than you intended)

@faker-js/members Should we document that somewhere or prepare a commamd for that like pnpm run testxecute/texecute? Currently only docs:dev ist documented.

@Shinigami92
Copy link
Copy Markdown
Member

IMO this is a really niche case. However you could store scripts in _local folder, because this folder will be ignored by the clean script.

"clean": "git clean -fdx --exclude _local",

@matthewmayer
Copy link
Copy Markdown
Contributor

Also whats the easiest way to run faker locally? via testing or starting pnpm run docs:dev and then using the browser console?

There are 4 ways. In descending order of my personal preference.

  • pnpm tsx my-test.ts (easy to repeat and debug, looking into complex values may require JSON.stringify, no need to switch windows)

  • pnpm run docs:dev and then via browser console (easy to look into array/complex values , you may need to run it/generate:apidocs repeatedly)

  • clone and use the playground or create your own (you may need to build/install repeatedly)

  • write a (temporary) test, (vitest may add noise to your logs or run more tests than you intended)

@faker-js/members Should we document that somewhere or prepare a commamd for that like pnpm run testxecute/texecute? Currently only docs:dev ist documented.

Personally I do

pnpm run build
node

Now you are in node REPL so can do like:

const {fakerCY}=require(".")
fakerCY.location.zipCode()

@ST-DDT
Copy link
Copy Markdown
Member

ST-DDT commented May 22, 2026

I created a separate issue to discuss dev verification tooling and documentation:

@ST-DDT
Copy link
Copy Markdown
Member

ST-DDT commented May 22, 2026

Just a heads up it will be away for a while before I can come back to this :)

Thanks for the heads up.

@ST-DDT what do you mean by 'cross-product this myself?' Is it that:

* Or do you mean I have to do it by "hand", as in change the content to `'CF# #??', 'CF## #??',` etc and remove `postcode_prefix`?

* update `/src/definitions/location.ts`?

I pushed a WIP commit of doing the latter, it seems to work. WIP as I would like to update some tests check that the other locales work as well and add documentation.

Sorry, for not being more clear.

I didn't mean add fake support.
I meant:

const suffixes = ['`## ##?', ...]
const prefixes = ['CY', ...]

export prefixes.flatMap(prefix => suffixes.map(suffix => prefix+suffix))

Either like this or only the result of it.

@ST-DDT ST-DDT marked this pull request as draft May 22, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: locale Permutes locale definitions m: location Something is referring to the location module p: 1-normal Nothing urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants