Skip to content

Commit 3583675

Browse files
committed
imp(phonenumber): now generates valid Swedish phone numbers
1 parent 8d12a6a commit 3583675

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

NOTES.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Notes
2+
3+
## Merging from Javafaker
4+
5+
```
6+
git remote add javafaker https://github.com/DiUS/java-faker.git\n
7+
git fetch javafaker pull/693/head:pr693
8+
git merge pr693
9+
```
10+
11+
## Publish docs
12+
13+
```
14+
mkdocs gh-deploy
15+
```
16+
17+
## Publish to maven central
18+
19+
```
20+
mvn deploy
21+
```
22+

docs/releases/1.1.0-snapshot.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ contributions to Datafaker.
1313
## Notable changes
1414

1515
* Breaking (minor) change: `Relationships` has been renamed to `Relationship`.
16-
* Bufix: Fixed Russian translation ([PR #693](https://github.com/DiUS/java-faker/issues/693) by Sergey Nuyanzin)
16+
* Bugfix: Fixed Russian translation ([PR #693](https://github.com/DiUS/java-faker/issues/693) by Sergey Nuyanzin)
1717
* Improvement: Added mountain ranges ([PR #696](https://github.com/DiUS/java-faker/pull/696) by Sergey Nuyanzin)
1818
* Improvement: Minimised external dependencies. Removed Guava and Apache Commons from production dependencies, and logging from test dependencies.
1919
* Improvement: New `examplify` method in Faker, which generates a value by example, with the same pattern as the input value. (See the Javadoc for examples). [PR #4](https://github.com/datafaker-net/datafaker/pull/4) by Amit Solankurkar.
2020
* Bugfix: Removed 226 area code as reported here [Issue #698](https://github.com/DiUS/java-faker/issues/698).
21+
* Improvement: Now supports valid Swedish (sv_SE) phone numbers

src/main/resources/sv.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ sv:
6060
- "#{prefix} #{first_name} #{last_name}"
6161

6262
phone_number:
63-
formats: ['####-#####', '####-######']
63+
area_code_3: ["011", "013", "016", "018", "019", "020", "021", "023", "026", "031", "033", "035", "036", "040", "042", "044", "046", "054", "060", "063"]
64+
area_code_4: ["0120", "0121", "0122", "0123", "0125", "0140", "0141", "0142", "0143", "0144", "0150", "0151", "0152", "0155", "0156", "0157", "0158", "0159", "0171", "0173", "0174", "0175", "0176", "0220", "0221", "0222", "0223", "0224", "0225", "0226", "0227", "0240", "0241", "0243", "0246", "0247", "0248", "0250", "0251", "0253", "0258", "0270", "0271", "0278", "0280", "0281", "0290", "0291", "0292", "0293", "0294", "0295", "0297", "0300", "0301", "0302", "0303", "0304", "0320", "0321", "0322", "0325", "0340", "0345", "0346", "0370", "0371", "0372", "0380", "0381", "0382", "0383", "0390", "0392", "0393", "0410", "0411", "0413", "0414", "0415", "0416", "0417", "0418", "0430", "0431", "0433", "0435", "0451", "0454", "0455", "0456", "0457", "0459", "0470", "0471", "0472", "0474", "0476", "0477", "0478", "0479", "0480", "0481", "0485", "0486", "0490", "0491", "0492", "0493", "0494", "0495", "0496", "0498", "0499", "0500", "0501", "0502", "0503", "0504", "0505", "0506", "0510", "0511", "0512", "0513", "0514", "0515", "0520", "0521", "0522", "0523", "0524", "0525", "0526", "0528", "0530", "0531", "0532", "0533", "0534", "0550", "0551", "0552", "0553", "0554", "0555", "0560", "0563", "0564", "0565", "0570", "0571", "0573", "0580", "0581", "0582", "0583", "0584", "0585", "0586", "0587", "0589", "0590", "0591", "0611", "0612", "0613", "0620", "0621", "0622", "0623", "0624", "0640", "0642", "0643", "0644", "0645", "0647", "0650", "0651", "0652", "0653", "0657", "0660", "0661", "0662", "0663", "0670", "0671", "0672", "0680", "0682", "0684", "0687", "0690", "0691", "0692", "0693", "0695", "0696", "0771", "0910", "0911", "0912", "0913", "0914", "0915", "0916", "0918", "0920", "0921", "0922", "0923", "0924", "0925", "0926", "0927", "0928", "0929", "0930", "0932", "0933", "0934", "0935", "0940", "0941", "0942", "0943", "0950", "0951", "0952", "0953", "0954", "0960", "0961", "0970", "0971", "0973", "0975", "0976", "0977", "0978", "0980"]
65+
formats:
66+
- "#{PhoneNumber.area_code_3}-#######"
67+
- "#{PhoneNumber.area_code_4}-######"
6468
cell_phone:
6569
formats:
6670
- '070-###-####'

src/test/java/net/datafaker/MoodTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.datafaker;
22

33
import org.junit.Test;
4-
54
import static net.datafaker.matchers.MatchesRegularExpression.matchesRegularExpression;
65
import static org.hamcrest.MatcherAssert.assertThat;
76

src/test/java/net/datafaker/PhoneNumberTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ public void testAllCellPhone_enUS() throws NumberParseException {
3131
assertTrue(util.isValidNumberForRegion(proto, "US"));
3232
}
3333

34+
final Faker sefaker = new Faker(new Locale("sv_SE"));
35+
36+
@Test
37+
@Repeat(times = 1000)
38+
public void testAllCellPhone_svSE() throws NumberParseException {
39+
String phoneNumber = sefaker.phoneNumber().phoneNumber();
40+
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
41+
Phonenumber.PhoneNumber proto = util.parse(phoneNumber, "SE");
42+
assertTrue(phoneNumber, util.isValidNumberForRegion(proto, "SE"));
43+
}
44+
3445
@Test
3546
public void testPhone_esMx() {
3647
final Faker f = new Faker(new Locale("es_MX"));

0 commit comments

Comments
 (0)