Skip to content

Commit

Permalink
refactor(location): use postcode fake patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Oct 29, 2024
1 parent ebd0dd0 commit 1ed32a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/definitions/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type LocationDefinition = LocaleEntry<{
/**
* Postcodes patterns.
*/
postcode: string | string[];
postcode_pattern: string[];

/**
* The patterns to generate city names.
Expand Down
12 changes: 3 additions & 9 deletions src/modules/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,9 @@ export class LocationModule extends ModuleBase {
return this.faker.helpers.replaceSymbols(format);
}

let zipPattern = this.faker.definitions.location.postcode;

if (typeof zipPattern === 'string') {
zipPattern = [zipPattern];
}

zipPattern = this.faker.helpers.arrayElement(zipPattern);

return this.faker.helpers.replaceSymbols(zipPattern);
return this.faker.helpers.fake(
this.faker.definitions.location.postcode_pattern
);
}

/**
Expand Down

0 comments on commit 1ed32a4

Please sign in to comment.