Repository: withastro/astro
File: packages/astro/src/core/errors/errors-data.ts (TypeScript)

Code before:
	title: 'Content entry data does not match schema.',
	message(collection: string, entryId: string, error: ZodError) {
		return [
			`**${String(collection)} → ${String(entryId)}** data does not match collection schema.`,
			...error.errors.map((zodError) => zodError.message),
		].join('\n');
	},
	hint: 'See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas.',
} satisfies ErrorData;

/**
 * @docs
 * @message
 * **Example error message:**<br/>
 * The content loader for the collection **blog** returned an invalid result:<br/>
 * Content entry `id` must be a string:<br/>
 * {<br/>
 * 	 "id": 1,<br/>
 * 	 "title": "Hello, World!"<br/>
 * }
 * @description
 * A content loader returned an invalid result.
 * Make sure that the ID of the entry is a string.
 * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information.
 */
export const ContentLoaderReturnsInvalidResult = {
	name: 'ContentLoaderReturnsInvalidResult',
	title: 'Content loader returns invalid result.',
	message(collection: string, entry: any, message: string) {
		return [
			`The content loader for the collection **${String(collection)}** returned an invalid result:`,
			`${message}:`,
			JSON.stringify(entry, null, 2),
		].join('\n');
	},
	hint: 'See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas.',
} satisfies ErrorData;

/**
 * @docs
 * @message
 * **Example error message:**<br/>
 * **blog** → **post** data does not match collection schema.<br/>
 * "title" is required.<br/>
 * "date" must be a valid date.
 * @description
 * A content entry does not match its collection schema.
 * Make sure that all required fields are present, and that all fields are of the correct type.
 * You can check against the collection schema in your `src/content.config.*` file.
 * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information.
 */

Review comment (suggestion):
```suggestion
export const ContentLoaderReturnsInvalidId = {
```
Just an e.g. based on my earlier question. There are probably lots of ways an entry can be invalid, so does it make sense to entirely base this on invalid ID

Code after:
export const InvalidContentEntryDataError = {
	name: 'InvalidContentEntryDataError',
	title: 'Content entry data does not match schema.',
	message(collection: string, entryId: string, error: ZodError) {
		return [
			`**${String(collection)} → ${String(entryId)}** data does not match collection schema.`,
			...error.errors.map((zodError) => zodError.message),
		].join('\n');
	},
	hint: 'See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas.',
} satisfies ErrorData;

/**
 * @docs
 * @message
 * **Example error message:**<br/>
 * The content loader for the collection **blog** returned an entry with an invalid `id`:<br/>
 * &#123;<br/>
 *   "id": 1,<br/>
 *   "title": "Hello, World!"<br/>
 * &#125;
 * @description
 * A content loader returned an invalid `id`.
 * Make sure that the `id` of the entry is a string.
 * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information.
 */
export const ContentLoaderReturnsInvalidId = {
	name: 'ContentLoaderReturnsInvalidId',
	title: 'Content loader returned an entry with an invalid `id`.',
	message(collection: string, entry: any) {
		return [
			`The content loader for the collection **${String(collection)}** returned an entry with an invalid \`id\`:`,
			JSON.stringify(entry, null, 2),
		].join('\n');
	},
	hint: 'Make sure that the `id` of the entry is a string. See https://docs.astro.build/en/guides/content-collections/ for more information on content loaders.',
} satisfies ErrorData;

/**
 * @docs
 * @message
 * **Example error message:**<br/>
 * **blog** → **post** data does not match collection schema.<br/>
 * "title" is required.<br/>
 * "date" must be a valid date.
 * @description
 * A content entry does not match its collection schema.
 * Make sure that all required fields are present, and that all fields are of the correct type.
 * You can check against the collection schema in your `src/content.config.*` file.
 * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information.
 */