Skip to content

Commit

Permalink
Merge 1a88c7a into 7a6e99f
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeLaptev committed Nov 26, 2019
2 parents 7a6e99f + 1a88c7a commit 00bd84b
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 30 deletions.
50 changes: 50 additions & 0 deletions src/main/resources/ca.yml
Expand Up @@ -29,3 +29,53 @@ ca:
- "#{first_name} #{last_name} #{last_name}"
color:
name: [aiguamarina, albercoc, amarant, ambre, ametista, atzur, beix, bistre, blanc, blat, blau, blau cel, blau fosc, blau marí, blau reial, blauet, bronze, camussa, canyella, caqui, cardenal, carmesí, carmí, carnació, castany rogenc, celadont, ceruli, chartreuse, cian, cirera, corall, coure, crema, escarlata, granat, gris, gris fosc, groc, lavanda, lila, llima, magenta, malva, marró, morat, ocre, or, orquídia, panotxa, plata, porpra, préssec, pruna, verd, verd maragda, verd oliva, verd veronès, vermell, vermell fosc, vermelló, vinca, violat, vori]
phone_number:
country_code: ['1']
area_code: [
'403', '587', '780', '825', # Alberta
'236', '250', '604', '672', '778', # British Columbia
'204', '431', # Manitoba
'506', # New Brunswick
'709', # Newfoundland and Labrador
'782', '902', # Nova Scotia and Prince Edward Island
'226', '249', '289', '343', '365', '416', '437', '519', '548', '613', '647', '705', '807', '905', # Ontario
'367', '418', '438', '450', '514', '579', '581', '819', '873', # Quebec
'306', '639', # Saskatchewan
'867' # Yukon, Northwest Territories and Nunavut
]
formats:
- '#{area_code}-###-####'
- '(#{area_code}) ###-####'
- '#{country_code}-#{area_code}-###-####'
- '#{area_code}.###.####'
- '#{area_code}-###-#### x###'
- '(#{area_code}) ###-#### x###'
- '#{country_code}-###-###-#### x###'
- '#{area_code}.###.#### x###'
- '#{area_code}-###-#### x####'
- '(#{area_code}) ###-#### x####'
- '#{country_code}-#{area_code}-###-#### x####'
- '#{area_code}.###.#### x####'
- '#{area_code}-###-#### x#####'
- '(#{area_code}) ###-#### x#####'
- '#{country_code}-#{area_code}-###-#### x#####'
- '#{area_code}.###.#### x#####'
cell_phone:
country_code: ['1']
area_code: [
'403', '587', '780', '825', # Alberta
'236', '250', '604', '672', '778', # British Columbia
'204', '431', # Manitoba
'506', # New Brunswick
'709', # Newfoundland and Labrador
'782', '902', # Nova Scotia and Prince Edward Island
'226', '249', '289', '343', '365', '416', '437', '519', '548', '613', '647', '705', '807', '905', # Ontario
'367', '418', '438', '450', '514', '579', '581', '819', '873', # Quebec
'306', '639', # Saskatchewan
'867' # Yukon, Northwest Territories and Nunavut
]
formats:
- '#{area_code}-###-####'
- '(#{area_code}) ###-####'
- '#{country_code}-#{area_code}-###-####'
- '#{area_code}.###.####'
72 changes: 48 additions & 24 deletions src/main/resources/en-CA.yml
Expand Up @@ -5,32 +5,56 @@ en-CA:
state: [Alberta, British Columbia, Manitoba, New Brunswick, Newfoundland and Labrador, Nova Scotia, Northwest Territories, Nunavut, Ontario, Prince Edward Island, Quebec, Saskatchewan, Yukon]
state_abbr: ["AB", "BC", "MB", "NB", "NL", "NS", "NU", "NT", "ON", "PE", "QC", "SK", "YT"]
default_country: [Canada]

internet:
free_email: [gmail.com, yahoo.ca, hotmail.com]
domain_suffix: [ca, com, biz, info, name, net, org]

phone_number:
area_code: ["204", "226", "236", "249", "250", "289", "306", "343", "365", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "579", "581", "587", "604", "613", "639", "647", "705", "709", "778", "780", "807", "819", "867", "873", "902", "905"]
exchange_code: ["201", "202", "203", "205", "206", "207", "208", "209", "210", "212", "213", "214", "215", "216", "217", "218", "219", "224", "225", "227", "228", "229", "231", "234", "239", "240", "248", "251", "252", "253", "254", "256", "260", "262", "267", "269", "270", "276", "281", "283", "301", "302", "303", "304", "305", "307", "308", "309", "310", "312", "313", "314", "315", "316", "317", "318", "319", "320", "321", "323", "330", "331", "334", "336", "337", "339", "347", "351", "352", "360", "361", "386", "401", "402", "404", "405", "406", "407", "408", "409", "410", "412", "413", "414", "415", "417", "419", "423", "424", "425", "434", "435", "440", "443", "445", "464", "469", "470", "475", "478", "479", "480", "484", "501", "502", "503", "504", "505", "507", "508", "509", "510", "512", "513", "515", "516", "517", "518", "520", "530", "540", "541", "551", "557", "559", "561", "562", "563", "564", "567", "570", "571", "573", "574", "580", "585", "586", "601", "602", "603", "605", "606", "607", "608", "609", "610", "612", "614", "615", "616", "617", "618", "619", "620", "623", "626", "630", "631", "636", "641", "646", "650", "651", "660", "661", "662", "667", "678", "682", "701", "702", "703", "704", "706", "707", "708", "712", "713", "714", "715", "716", "717", "718", "719", "720", "724", "727", "731", "732", "734", "737", "740", "754", "757", "760", "763", "765", "770", "772", "773", "774", "775", "781", "785", "786", "801", "802", "803", "804", "805", "806", "808", "810", "812", "813", "814", "815", "816", "817", "818", "828", "830", "831", "832", "835", "843", "845", "847", "848", "850", "856", "857", "858", "859", "860", "862", "863", "864", "865", "870", "872", "878", "901", "903", "904", "906", "907", "908", "909", "910", "912", "913", "914", "915", "916", "917", "918", "919", "920", "925", "928", "931", "936", "937", "940", "941", "947", "949", "952", "954", "956", "959", "970", "971", "972", "973", "975", "978", "979", "980", "984", "985", "989"]
country_code: ['1']
area_code: [
'403', '587', '780', '825', # Alberta
'236', '250', '604', '672', '778', # British Columbia
'204', '431', # Manitoba
'506', # New Brunswick
'709', # Newfoundland and Labrador
'782', '902', # Nova Scotia and Prince Edward Island
'226', '249', '289', '343', '365', '416', '437', '519', '548', '613', '647', '705', '807', '905', # Ontario
'367', '418', '438', '450', '514', '579', '581', '819', '873', # Quebec
'306', '639', # Saskatchewan
'867' # Yukon, Northwest Territories and Nunavut
]
formats:
- "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}"
- "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}"
- "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}"
- "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number}"
- "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}"
- "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}"
- "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number}"
- "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number}"
- "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "(#{PhoneNumber.area_code}) #{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "1-#{PhoneNumber.area_code}-#{PhoneNumber.exchange_code}-#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- "#{PhoneNumber.area_code}.#{PhoneNumber.exchange_code}.#{PhoneNumber.subscriber_number} x#{PhoneNumber.extension}"
- '#{area_code}-###-####'
- '(#{area_code}) ###-####'
- '#{country_code}-#{area_code}-###-####'
- '#{area_code}.###.####'
- '#{area_code}-###-#### x###'
- '(#{area_code}) ###-#### x###'
- '#{country_code}-###-###-#### x###'
- '#{area_code}.###.#### x###'
- '#{area_code}-###-#### x####'
- '(#{area_code}) ###-#### x####'
- '#{country_code}-#{area_code}-###-#### x####'
- '#{area_code}.###.#### x####'
- '#{area_code}-###-#### x#####'
- '(#{area_code}) ###-#### x#####'
- '#{country_code}-#{area_code}-###-#### x#####'
- '#{area_code}.###.#### x#####'
cell_phone:
country_code: ['1']
area_code: [
'403', '587', '780', '825', # Alberta
'236', '250', '604', '672', '778', # British Columbia
'204', '431', # Manitoba
'506', # New Brunswick
'709', # Newfoundland and Labrador
'782', '902', # Nova Scotia and Prince Edward Island
'226', '249', '289', '343', '365', '416', '437', '519', '548', '613', '647', '705', '807', '905', # Ontario
'367', '418', '438', '450', '514', '579', '581', '819', '873', # Quebec
'306', '639', # Saskatchewan
'867' # Yukon, Northwest Territories and Nunavut
]
formats:
- '#{area_code}-###-####'
- '(#{area_code}) ###-####'
- '#{country_code}-#{area_code}-###-####'
- '#{area_code}.###.####'
2 changes: 1 addition & 1 deletion src/main/resources/en/phone_number.yml
@@ -1,7 +1,7 @@
en:
faker:
phone_number:
formats: ['###-###-####', '(###) ###-####', '1-###-###-####', '###.###.####', '###-###-####', '(###) ###-####', '1-###-###-####', '###.###.####', '###-###-#### x###', '(###) ###-#### x###', '1-###-###-#### x###', '###.###.#### x###', '###-###-#### x####', '(###) ###-#### x####', '1-###-###-#### x####', '###.###.#### x####', '###-###-#### x#####', '(###) ###-#### x#####', '1-###-###-#### x#####', '###.###.#### x#####']
formats: ['###-###-####', '(###) ###-####', '1-###-###-####', '###.###.####', '###-###-#### x###', '(###) ###-#### x###', '1-###-###-#### x###', '###.###.#### x###', '###-###-#### x####', '(###) ###-#### x####', '1-###-###-#### x####', '###.###.#### x####', '###-###-#### x#####', '(###) ###-#### x#####', '1-###-###-#### x#####', '###.###.#### x#####']
cell_phone:
formats: ['###-###-####', '(###) ###-####', '1-###-###-####', '###.###.####']
country_code: ["1", "1-242", "1-246", "1-264", "1-268", "1-284", "1-340", "1-345", "1-441", "1-473", "1-649", "1-670", "1-671", "1-684", "1-758", "1-784", "1-787", "1-868", "1-869", "1-876", "1-939", "20", "212", "213", "216", "218", "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", "230", "231", "232", "233", "234", "235", "236", "238", "238", "239", "240", "241", "242", "243", "244", "245", "247", "248", "249", "250", "251", "252", "253", "254", "255", "256", "257", "258", "260", "261", "262", "263", "264", "265", "266", "267", "268", "269", "269", "27", "290", "291", "297", "298", "299", "30", "31", "32", "33", "33", "34", "350", "351", "352", "353", "354", "355", "356", "357", "358", "359", "36", "370", "371", "372", "373", "374", "375", "376", "378", "380", "381", "381", "381", "385", "386", "387", "389", "39", "39", "40", "41", "420", "421", "423", "43", "44", "45", "46", "47", "48", "49", "500", "501", "502", "503", "504", "505", "506", "507", "508", "509", "51", "52", "53", "54", "55", "56", "57", "58", "591", "592", "593", "594", "595", "596", "596", "597", "598", "599", "60", "61", "61-8", "62", "63", "64", "65", "66", "670", "672", "673", "674", "675", "676", "677", "678", "679", "680", "681", "682", "683", "685", "686", "687", "688", "689", "690", "691", "692", "7", "7-6", "7-7", "767", "809", "809", "809", "81", "82", "84", "850", "850", "852", "853", "855", "855", "856", "86", "880", "886", "886", "90", "91", "92", "93", "94", "95", "960", "961", "962", "963", "964", "965", "966", "967", "968", "971", "972", "973", "974", "975", "976", "977", "98", "993", "994", "995", "996"]
26 changes: 21 additions & 5 deletions src/test/java/com/github/javafaker/PhoneNumberTest.java
@@ -1,12 +1,11 @@
package com.github.javafaker;

import org.junit.Test;

import java.util.Locale;

import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
import static org.junit.Assert.assertThat;

import java.util.Locale;
import org.junit.Test;

public class PhoneNumberTest extends AbstractFakerTest {

@Test
Expand All @@ -18,12 +17,29 @@ public void testCellPhone_enUS() {
@Test
public void testPhone_esMx() {
final Faker f = new Faker(new Locale("es_MX"));
for (int i=0;i<100;i++) {
for (int i = 0; i < 100; i++) {
assertThat(f.phoneNumber().cellPhone(), matchesRegularExpression("(044 )?\\(?\\d+\\)?([- .]\\d+){1,3}"));
assertThat(f.phoneNumber().phoneNumber(), matchesRegularExpression("\\(?\\d+\\)?([- .]\\d+){1,3}"));
}
}

@Test
public void testPhone_CA() {
final Locale[] locales = new Locale[]{Locale.CANADA, new Locale("ca")};
for (Locale locale : locales) {
final Faker f = new Faker(locale);
final String canadianAreaCode = "403|587|780|825|236|250|604|672|778|204|431|506|"
+ "709|782|902|226|249|289|343|365|416|437|519|548|613|647|705|807|905|367|"
+ "418|438|450|514|579|581|819|873|306|639|867";
for (int i = 0; i < 100; i++) {
assertThat(f.phoneNumber().cellPhone(),
matchesRegularExpression(
String.format("((1-)?(\\(?(%s)\\)?)|(%s))[- .]\\d{3}[- .]\\d{4}",
canadianAreaCode, canadianAreaCode)));
}
}
}

@Test
public void testCellPhone() {
assertThat(faker.phoneNumber().cellPhone(), matchesRegularExpression("\\(?\\d+\\)?([- .]\\d+){1,3}"));
Expand Down

0 comments on commit 00bd84b

Please sign in to comment.