|
Lines 14-22
const generateMockData = (type, properties) => {
Link Here
|
| 14 |
switch (type) { |
14 |
switch (type) { |
| 15 |
case "string": |
15 |
case "string": |
| 16 |
if (properties?.maxLength) { |
16 |
if (properties?.maxLength) { |
|
|
17 |
// The propability to have a string with length=1 is the same as length=10 |
| 18 |
// We have very limited pool of possible values for length=1 which will result in a "Duplicate ID" error from the server |
| 19 |
// Setting minLength to 3 to prevent this kind of failures |
| 20 |
let minLength = |
| 21 |
properties.minLength === 1 || |
| 22 |
properties.minLength === undefined |
| 23 |
? 3 |
| 24 |
: properties.minLength; |
| 25 |
minLenth = |
| 26 |
properties.maxLength !== undefined && |
| 27 |
properties.maxLength > 3 |
| 28 |
? 3 |
| 29 |
: minLength; |
| 17 |
return (value = faker.string.alpha({ |
30 |
return (value = faker.string.alpha({ |
| 18 |
length: { |
31 |
length: { |
| 19 |
min: properties.minLength || 1, |
32 |
min: minLength, |
| 20 |
max: properties.maxLength, |
33 |
max: properties.maxLength, |
| 21 |
}, |
34 |
}, |
| 22 |
})); |
35 |
})); |
| 23 |
- |
|
|