From 41ebbbbe4432b7583f4bd51c5339be0af8ed09c9 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Fri, 28 Feb 2025 08:24:02 +0100 Subject: docs: improve missing data error (#3406) --- src/faker.ts | 5 ++++- src/internal/locale-proxy.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/faker.ts b/src/faker.ts index 0b03788b..d9e9905b 100644 --- a/src/faker.ts +++ b/src/faker.ts @@ -120,7 +120,9 @@ export class Faker extends SimpleFaker { * For more information see our [Localization Guide](https://fakerjs.dev/guide/localization.html). * * @param options The options to use. - * @param options.locale The locale data to use. + * @param options.locale The locale data to use for this instance. + * If an array is provided, the first locale that has a definition for a given property will be used. + * Please make sure that all required locales and their parent locales are present, e.g. `[de_AT, de, en, base]`. * @param options.randomizer The Randomizer to use. * Specify this only if you want to use it to achieve a specific goal, * such as sharing the same random generator with other instances/tools. @@ -148,6 +150,7 @@ export class Faker extends SimpleFaker { /** * The locale data to use for this instance. * If an array is provided, the first locale that has a definition for a given property will be used. + * Please make sure that all required locales and their parent locales are present, e.g. `[de_AT, de, en, base]`. * * @see mergeLocales(): For more information about how the locales are merged. */ diff --git a/src/internal/locale-proxy.ts b/src/internal/locale-proxy.ts index dbb9f277..3e77a93a 100644 --- a/src/internal/locale-proxy.ts +++ b/src/internal/locale-proxy.ts @@ -72,6 +72,7 @@ export function assertLocaleData( } else if (value === undefined) { throw new FakerError( `The locale data for '${path.join('.')}' are missing in this locale. + If this is a custom Faker instance, please make sure all required locales are used e.g. '[de_AT, de, en, base]'. Please contribute the missing data to the project or use a locale/Faker instance that has these data. For more information see https://fakerjs.dev/guide/localization.html` ); -- cgit v1.2.3