aboutsummaryrefslogtreecommitdiff
path: root/src/modules/location
diff options
context:
space:
mode:
authorMatt Mayer <[email protected]>2023-08-10 18:37:17 +0100
committerGitHub <[email protected]>2023-08-10 19:37:17 +0200
commit0ca1e442d6a882677fc73012fc481d48ca1905a5 (patch)
tree84b2ca509e5a126cd0e7c033fc1fc5f14a8f8f08 /src/modules/location
parent7f0daf3ddaa8956dc393964362eb696e23dc57d6 (diff)
downloadfaker-0ca1e442d6a882677fc73012fc481d48ca1905a5.tar.xz
faker-0ca1e442d6a882677fc73012fc481d48ca1905a5.zip
fix(location): Pad en_US ZIP codes left to 5 characters if needed (#2278)
* fix(location): Pad en_US ZIP codes left to 5 characters if needed * fix NJ and RI * fix PR * updated postcode_by_state to use string patterns --------- Co-authored-by: DivisionByZero <[email protected]>
Diffstat (limited to 'src/modules/location')
-rw-r--r--src/modules/location/index.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts
index cdfa44d0..175c5433 100644
--- a/src/modules/location/index.ts
+++ b/src/modules/location/index.ts
@@ -65,10 +65,11 @@ export class LocationModule {
const { state } = options;
if (state) {
- const zipRange = this.faker.definitions.location.postcode_by_state[state];
+ const zipPattern: string =
+ this.faker.definitions.location.postcode_by_state[state];
- if (zipRange) {
- return String(this.faker.number.int(zipRange));
+ if (zipPattern) {
+ return this.faker.helpers.fake(zipPattern);
}
throw new FakerError(`No zip code definition found for state "${state}"`);