Description
Current Behavior
When a structured data object uses a @type that is not a valid schema.org type (e.g., "@type": "BananaPhone"), the validator silently skips it without returning any error or warning.
Currently:
- If the type has no registered handler in
validator.js, it logs a debug warning and returns an empty array
- The
schemaOrg.js global handler only validates properties, not the type itself
- Users receive no feedback that their type is invalid
Expected Behavior
The validator should return a warning when a @type is not a valid schema.org type, helping users catch typos or made-up types early.
Proposed Implementation
-
Modify schemaOrg.js to check if the type exists in the loaded schema.org specification before validating properties:
const schema = await this.#loadSchema();
const typeId = this.#stripSchema(this.type);
if (!schema[typeId]) {
issues.push({
issueMessage: `Type "${typeId}" is not a valid schema.org type`,
severity: 'WARNING',
path: this.path,
errorType: 'schemaOrg',
fieldName: '@type',
});
return issues;
}
-
Modify validator.js to ensure the schemaOrg handler runs even for types without a registered handler (so completely unknown types are also validated)
Acceptance Criteria
Description
Current Behavior
When a structured data object uses a
@typethat is not a valid schema.org type (e.g.,"@type": "BananaPhone"), the validator silently skips it without returning any error or warning.Currently:
validator.js, it logs a debug warning and returns an empty arrayschemaOrg.jsglobal handler only validates properties, not the type itselfExpected Behavior
The validator should return a warning when a
@typeis not a valid schema.org type, helping users catch typos or made-up types early.Proposed Implementation
Modify
schemaOrg.jsto check if the type exists in the loaded schema.org specification before validating properties:Modify
validator.jsto ensure the schemaOrg handler runs even for types without a registered handler (so completely unknown types are also validated)Acceptance Criteria