Skip to content

Commit d2ed3c9

Browse files
committed
add Polish data
1 parent ac8e874 commit d2ed3c9

File tree

10 files changed

+3068
-0
lines changed

10 files changed

+3068
-0
lines changed

api/.nextRelease/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ class Generator {
402402
NL: "Netherlands",
403403
NO: "Norway",
404404
NZ: "New Zealand",
405+
PL: "Poland",
405406
RS: "Serbia",
406407
TR: "Turkey",
407408
UA: "Ukraine",

api/.nextRelease/data/PL/inject.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const { transliterate } = require('transliteration');
2+
const { random, include, pad, randomItem } = require('../../api');
3+
4+
module.exports = (inc, contents, datasets) => {
5+
const lastName = contents.gender === 'male' ? randomItem(datasets['PL'].male_last) : randomItem(datasets['PL'].female_last);
6+
7+
include(inc, contents, 'phone', `+48 ${random(3, 3)} ${random(3, 3)} ${random(3, 3)}`);
8+
9+
include(inc, contents, 'cell', `+48 ${random(3, 3)} ${random(3, 3)} ${random(3, 3)}`);
10+
11+
include(inc, contents, 'id', () => {
12+
const dobDate = new Date(contents.dob.date);
13+
const generatePesel = () => {
14+
const pesel = `${dobDate.getFullYear().toString().slice(-2)
15+
}${pad(dobDate.getMonth() + 1, 2)
16+
}${pad(dobDate.getDate(), 2)
17+
}${random(3, 3)
18+
}${contents.gender === 'male' ? randomItem([1, 3, 5, 7, 9]) : randomItem([0, 2, 4, 6, 8]) // odd number for man, even number for woman
19+
}`
20+
const checksum = 10 - ((pesel[0] * 1 + pesel[1] * 3 + pesel[2] * 7 + pesel[3] * 9 + pesel[4] * 1 + pesel[5] * 3 +
21+
pesel[6] * 7 + pesel[7] * 9 + pesel[8] * 1 + pesel[9] * 3) % 10) % 10;
22+
23+
return `${pesel}${checksum}`;
24+
};
25+
contents.id = {
26+
name: 'PESEL',
27+
value: generatePesel()
28+
}
29+
});
30+
31+
include(inc, contents, 'location', () => {
32+
contents.location.postcode = `${random(3, 2)}-${random(3, 3)}`;
33+
});
34+
35+
include(inc, contents, 'name', () => {
36+
contents.name.title = contents.gender === 'male' ? 'Pan' : 'Pani';
37+
contents.name.last = lastName;
38+
});
39+
40+
include(inc, contents, 'email', () => {
41+
contents.email = transliterate(`${contents.name.first}.${lastName}`).replace(/ /g, '').toLowerCase() + '@example.com'
42+
});
43+
44+
};

0 commit comments

Comments
 (0)