From 0ca1e442d6a882677fc73012fc481d48ca1905a5 Mon Sep 17 00:00:00 2001 From: Matt Mayer <152770+matthewmayer@users.noreply.github.com> Date: Thu, 10 Aug 2023 18:37:17 +0100 Subject: 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 --- src/modules/location/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/modules') 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}"`); -- cgit v1.2.3