diff options
| author | Karl Hughes <[email protected]> | 2018-01-20 11:23:02 -0600 |
|---|---|---|
| committer | Karl Hughes <[email protected]> | 2018-01-20 11:23:02 -0600 |
| commit | fd6df80f2e3b7a3d985dcdac9593cca23af06cf3 (patch) | |
| tree | 8913c382904f8969ef9d8c737e1c0037d223ebb2 /lib | |
| parent | 220e5cbff3ac8bd437619c5df712bbfb8622895d (diff) | |
| download | faker-fd6df80f2e3b7a3d985dcdac9593cca23af06cf3.tar.xz faker-fd6df80f2e3b7a3d985dcdac9593cca23af06cf3.zip | |
Adding test for zipcode by state, basic functionality
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/address.js | 9 | ||||
| -rw-r--r-- | lib/index.js | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/address.js b/lib/address.js index 21e14ff6..64742f8a 100644 --- a/lib/address.js +++ b/lib/address.js @@ -26,6 +26,15 @@ function Address (faker) { return Helpers.replaceSymbols(format); } + + this.zipCodeByState = function (state) { + var zipFormat = faker.definitions.address.postcode_by_state[state]; + if (zipFormat) { + return this.zipCode(zipFormat); + } + return undefined; + } + /** * Generates a random localized city name. The format string can contain any * method provided by faker wrapped in `{{}}`, e.g. `{{name.firstName}}` in diff --git a/lib/index.js b/lib/index.js index cd1a6cda..30ea96bc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -101,7 +101,7 @@ function Faker (opts) { var _definitions = { "name": ["first_name", "last_name", "prefix", "suffix", "gender", "title", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"], - "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode", "direction", "direction_abbr"], + "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode", "postcode_by_state", "direction", "direction_abbr"], "company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"], "lorem": ["words"], "hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb", "phrase"], |
