aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarak <[email protected]>2015-07-08 20:56:02 -0700
committerMarak <[email protected]>2015-07-08 20:56:02 -0700
commitd44c5a4b355c2b29b860bd8edf123b73ddd2c3a4 (patch)
tree46f76f47e5ef44ad2b6de21c4ab72ba47756440a /lib
parent18055d7183f0d9db7199a975a01f39b52985d668 (diff)
parent2e0cb637011e43820fe1066a6ebbfb0b828ecb07 (diff)
downloadfaker-d44c5a4b355c2b29b860bd8edf123b73ddd2c3a4.tar.xz
faker-d44c5a4b355c2b29b860bd8edf123b73ddd2c3a4.zip
Merge pull request #234 from portse/master
[fix] Canadian zip format broken after locale spliting
Diffstat (limited to 'lib')
-rw-r--r--lib/address.js22
-rw-r--r--lib/index.js2
-rw-r--r--lib/locales/en/address/index.js1
-rw-r--r--lib/locales/en/address/zipFormat.js4
-rw-r--r--lib/locales/en_CA/address/index.js1
-rw-r--r--lib/locales/en_CA/address/postcode.js3
6 files changed, 16 insertions, 17 deletions
diff --git a/lib/address.js b/lib/address.js
index d53e0ef8..a921903f 100644
--- a/lib/address.js
+++ b/lib/address.js
@@ -2,17 +2,17 @@ function Address (faker) {
var f = faker.fake,
Helpers = faker.helpers;
- this.zipCode = function (format) {
- // if zip format is not specified, use the zip format defined for the locale
- if (typeof format === 'undefined') {
- var localeFormat = faker.definitions.address.zipFormat;
- if (typeof localeFormat === 'string') {
- format = localeFormat;
- } else {
- format = faker.random.array_element(localeFormat);
- }
- }
- return Helpers.replaceSymbols(format);
+ this.zipCode = function(format) {
+ // if zip format is not specified, use the zip format defined for the locale
+ if (typeof format === 'undefined') {
+ var localeFormat = faker.definitions.address.postcode;
+ if (typeof localeFormat === 'string') {
+ format = localeFormat;
+ } else {
+ format = faker.random.array_element(localeFormat);
+ }
+ }
+ return Helpers.replaceSymbols(format);
}
this.city = function (format) {
diff --git a/lib/index.js b/lib/index.js
index 23ec1dee..07a0f825 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -83,7 +83,7 @@ function Faker (opts) {
var _definitions = {
"name": ["first_name", "last_name", "prefix", "suffix", "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", "zipFormat"],
+ "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode"],
"company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"],
"lorem": ["words"],
"hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb"],
diff --git a/lib/locales/en/address/index.js b/lib/locales/en/address/index.js
index a71a498e..575f1d46 100644
--- a/lib/locales/en/address/index.js
+++ b/lib/locales/en/address/index.js
@@ -1,6 +1,5 @@
var address = {};
module['exports'] = address;
-address.zipFormat = require("./zipFormat");
address.city_prefix = require("./city_prefix");
address.city_suffix = require("./city_suffix");
address.county = require("./county");
diff --git a/lib/locales/en/address/zipFormat.js b/lib/locales/en/address/zipFormat.js
deleted file mode 100644
index f233d46c..00000000
--- a/lib/locales/en/address/zipFormat.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module["exports"] = [
- "#####",
- "#####-####"
-];
diff --git a/lib/locales/en_CA/address/index.js b/lib/locales/en_CA/address/index.js
index 8eaaa997..5b43a214 100644
--- a/lib/locales/en_CA/address/index.js
+++ b/lib/locales/en_CA/address/index.js
@@ -3,3 +3,4 @@ module['exports'] = address;
address.state = require("./state");
address.state_abbr = require("./state_abbr");
address.default_country = require("./default_country");
+address.postcode = require('./postcode.js');
diff --git a/lib/locales/en_CA/address/postcode.js b/lib/locales/en_CA/address/postcode.js
new file mode 100644
index 00000000..cd73ce97
--- /dev/null
+++ b/lib/locales/en_CA/address/postcode.js
@@ -0,0 +1,3 @@
+module["exports"] = [
+ "?#? #?#"
+];