Skip to content

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

Merged
ST-DDT merged 2 commits into
faker-js:nextfrom
IestynGage:next
May 28, 2026
Merged

feat(locale): add Welsh (cy) postcode definitions#3851
ST-DDT merged 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

netlify Bot commented May 19, 2026

Copy link
Copy Markdown

Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7f580b7
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a1673a585eb870008812dbc
😎 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.

Comment thread src/locales/cy/location/postcode.ts Outdated
@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.92%. Comparing base (03252b9) to head (7f580b7).

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

@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

@ST-DDT ST-DDT left a comment

Copy link
Copy Markdown
Member

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

IestynGage commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

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

ST-DDT commented May 22, 2026

Copy link
Copy Markdown
Member

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

ST-DDT commented May 22, 2026

Copy link
Copy Markdown
Member

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

@ST-DDT

ST-DDT commented May 22, 2026

Copy link
Copy Markdown
Member

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
Similiar to the `en_GB` postcode definitions with prefix as recommened by @matthewmayer,
as well as using code suggestions from @ST-DDT.
@IestynGage

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback & knowledge ❤️ After your first comment I was using pnpm run docs:dev

🤦 I can't belive it didn't occur to me to just combine two arrays together with map/flatmap. It's much clearer now :)

@IestynGage
IestynGage marked this pull request as ready for review May 26, 2026 23:29
@ST-DDT

ST-DDT commented May 27, 2026

Copy link
Copy Markdown
Member

I'm glad I was able to help.

@ST-DDT
ST-DDT added this pull request to the merge queue May 28, 2026
Merged via the queue into faker-js:next with commit 1afbd59 May 28, 2026
23 checks passed
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