Skip to content

Commit 1b4ea0a

Browse files
authored
Merge branch 'next' into locale/pt-pt-addresses
2 parents fcd0193 + bb72a66 commit 1b4ea0a

6 files changed

Lines changed: 47 additions & 14 deletions

File tree

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ The sources are located in the [src](src) directory.
2121
All fake data generators are divided into namespaces (each namespace being a separate module).
2222
Most of the generators use the _definitions_, which are just plain JavaScript objects/arrays/strings that are separate for each [locale](src/locales).
2323

24+
## Sourcing data for definitions
25+
26+
If adding new data definitions to Faker, you'll often need to find source data. Note that:
27+
28+
- Faker must not contain copyrighted materials.
29+
- Facts cannot be copyrighted, so if you are adding or translating a finite, known, list of things such as the names of chemical elements into another language, that's OK.
30+
- But if you are compiling a list of, for example, popular personal names or cities, don't copy directly from a single source (Wikipedia, 'most popular' articles, government data sites etc). A compilation of facts [can be copyrighted](https://en.wikipedia.org/wiki/Copyright_in_compilation).
31+
- It's best to refer to multiple sources and use your own judgement/knowledge to make a sample list of data.
32+
2433
## Building Faker
2534

2635
The project is being built by [esbuild](https://esbuild.github.io) (see [bundle.ts](scripts/bundle.ts))

src/locales/az/company/name_patterns.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@ export default [
22
'{{company.prefix}} {{person.female_first_name}}',
33
'{{company.prefix}} {{person.male_first_name}}',
44
'{{company.prefix}} {{person.male_last_name}}',
5-
'{{company.prefix}} {{company.suffix}}{{company.suffix}}',
6-
'{{company.prefix}} {{company.suffix}}{{company.suffix}}{{company.suffix}}',
7-
'{{company.prefix}} {{location.city_name}}{{company.suffix}}',
8-
'{{company.prefix}} {{location.city_name}}{{company.suffix}}{{company.suffix}}',
9-
'{{company.prefix}} {{location.city_name}}{{company.suffix}}{{company.suffix}}{{company.suffix}}',
105
];

src/locales/en_AU/person/last_name.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default [
4545
'Johnston',
4646
'Moore',
4747
'Smyth',
48-
"O'neill",
48+
"O'Neill",
4949
'Doherty',
5050
'Stewart',
5151
'Quinn',
@@ -121,7 +121,7 @@ export default [
121121
'Crooks',
122122
'Cruickshank',
123123
'Cummings',
124-
"D'amore",
124+
"D'Amore",
125125
'Daniel',
126126
'Dare',
127127
'Daugherty',
@@ -235,12 +235,12 @@ export default [
235235
'Nader',
236236
'Nicolas',
237237
'Nolan',
238-
"O'connell",
239-
"O'conner",
240-
"O'hara",
241-
"O'keefe",
238+
"O'Connell",
239+
"O'Conner",
240+
"O'Hara",
241+
"O'Keefe",
242242
'Olson',
243-
"O'reilly",
243+
"O'Reilly",
244244
'Parisian',
245245
'Parker',
246246
'Quigley',

src/locales/pt_BR/location/city.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
export default [
2-
'{{location.city_prefix}} {{person.firstName}}{{location.city_suffix}}',
3-
'{{location.city_prefix}} {{person.firstName}}',
42
'{{person.firstName}}{{location.city_suffix}}',
53
'{{person.lastName}}{{location.city_suffix}}',
64
];

src/modules/internet/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ export class InternetModule {
109109
);
110110
}
111111

112+
// local parts may not contain two or more consecutive . characters
113+
localPart = localPart.replace(/\.{2,}/g, '.');
114+
115+
// local parts may not start with or end with a . character
116+
localPart = localPart.replace(/^\./, '');
117+
localPart = localPart.replace(/\.$/, '');
118+
112119
return `${localPart}@${provider}`;
113120
}
114121

test/internet.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,30 @@ describe('internet', () => {
133133
expect(faker.definitions.internet.free_email).toContain(suffix);
134134
});
135135

136+
it('should not allow an email that starts or ends with a .', () => {
137+
const email = faker.internet.email('...Aiden...', '...Doe...');
138+
139+
expect(email).toBeTruthy();
140+
expect(email).toBeTypeOf('string');
141+
expect(email).toSatisfy(validator.isEmail);
142+
143+
const [prefix] = email.split('@');
144+
expect(prefix).not.toMatch(/^\./);
145+
expect(prefix).not.toMatch(/\.$/);
146+
});
147+
148+
it('should not allow an email with multiple dots', () => {
149+
const email = faker.internet.email('Ai....den');
150+
151+
expect(email).toBeTruthy();
152+
expect(email).toBeTypeOf('string');
153+
expect(email).toSatisfy(validator.isEmail);
154+
155+
const [prefix] = email.split('@');
156+
//expect it not to contain multiple .s
157+
expect(prefix).not.toMatch(/\.{2,}/);
158+
});
159+
136160
it('should return an email with given firstName and lastName', () => {
137161
const email = faker.internet.email('Aiden', 'Harann');
138162

0 commit comments

Comments
 (0)