Skip to content

Commit f8f9ef1

Browse files
committed
docs: improve missing data error
1 parent 6f1a0f8 commit f8f9ef1

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

src/faker.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export class Faker extends SimpleFaker {
120120
* For more information see our [Localization Guide](https://fakerjs.dev/guide/localization.html).
121121
*
122122
* @param options The options to use.
123-
* @param options.locale The locale data to use.
123+
* @param options.locale The locale data to use for this instance.
124+
* If an array is provided, the first locale that has a definition for a given property will be used.
125+
* Please make sure that all required locales including parent locales are present e.g. `[de_AT, de, en, base]`.
124126
* @param options.randomizer The Randomizer to use.
125127
* Specify this only if you want to use it to achieve a specific goal,
126128
* such as sharing the same random generator with other instances/tools.
@@ -148,6 +150,7 @@ export class Faker extends SimpleFaker {
148150
/**
149151
* The locale data to use for this instance.
150152
* If an array is provided, the first locale that has a definition for a given property will be used.
153+
* Please make sure that all required locales including parent locales are present e.g. `[de_AT, de, en, base]`.
151154
*
152155
* @see mergeLocales(): For more information about how the locales are merged.
153156
*/

src/internal/locale-proxy.ts

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export function assertLocaleData<T>(
7272
} else if (value === undefined) {
7373
throw new FakerError(
7474
`The locale data for '${path.join('.')}' are missing in this locale.
75+
If this is a custom Faker instance, please make sure all required locales are used e.g. '[de_AT, de, en, base]'.
7576
Please contribute the missing data to the project or use a locale/Faker instance that has these data.
7677
For more information see https://fakerjs.dev/guide/localization.html`
7778
);

test/internal/locale-proxy.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ describe('LocaleProxy', () => {
9797
expect(() => locale.category.missing).toThrow(
9898
new FakerError(
9999
`The locale data for 'category.missing' are missing in this locale.
100+
If this is a custom Faker instance, please make sure all required locales are used e.g. '[de_AT, de, en, base]'.
100101
Please contribute the missing data to the project or use a locale/Faker instance that has these data.
101102
For more information see https://fakerjs.dev/guide/localization.html`
102103
)
@@ -107,6 +108,7 @@ describe('LocaleProxy', () => {
107108
expect(() => locale.airline.missing).toThrow(
108109
new FakerError(
109110
`The locale data for 'airline.missing' are missing in this locale.
111+
If this is a custom Faker instance, please make sure all required locales are used e.g. '[de_AT, de, en, base]'.
110112
Please contribute the missing data to the project or use a locale/Faker instance that has these data.
111113
For more information see https://fakerjs.dev/guide/localization.html`
112114
)

test/modules/location.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ describe('location', () => {
220220
expect(() => faker.location.zipCode({ state: 'XX' })).toThrow(
221221
new FakerError(
222222
`The locale data for 'location.postcode_by_state' are missing in this locale.
223+
If this is a custom Faker instance, please make sure all required locales are used e.g. '[de_AT, de, en, base]'.
223224
Please contribute the missing data to the project or use a locale/Faker instance that has these data.
224225
For more information see https://fakerjs.dev/guide/localization.html`
225226
)

0 commit comments

Comments
 (0)