feat: Add validation for invalid schema.org types#60
Open
gsriram24 wants to merge 4 commits intoadobe:mainfrom
Open
feat: Add validation for invalid schema.org types#60gsriram24 wants to merge 4 commits intoadobe:mainfrom
gsriram24 wants to merge 4 commits intoadobe:mainfrom
Conversation
- Add validateType() method to schemaOrg.js to check if type exists in schema.org - Modify validator.js to always run global handlers even for unknown types - Return warning when @type is not a valid schema.org type - Add fieldName to validation errors for consistency - Add test case for invalid type detection - Exclude test files with Google-specific extensions from schema.org validation
noruiz
reviewed
Jan 28, 2026
herzog31
requested changes
Jan 29, 2026
Member
There was a problem hiding this comment.
Regarding startOffset-input, there are multiple aspects here:
- Generally the
-inputand-outputsuffixes are allowed as part of the schema.org spec under https://schema.org/docs/actions.html#part-4. - IIUC this however only applies to specific attributes, e.g. part of the
schema:PropertyValueSpecificationdomain. startOffsetis not part of that.
For consistency I recommend to globally allow -input and -output suffixes for all schema.org properties. I don't want to discourage users from using startOffset-input.
Everything else looks great, thank you 💯
Per the schema.org Actions specification, properties can have -input and -output suffixes to indicate input/output constraints. This change strips these suffixes before validating the base property name. See: https://schema.org/docs/actions.html#part-4 Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
@herzog31 , addressed this comment and added support for |
herzog31
reviewed
Feb 2, 2026
Member
herzog31
left a comment
There was a problem hiding this comment.
@gsriram24 Could you please update this PR against main and change fieldName to fieldNames (according to #57)? Then PR looks good and is ready to be merged 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a structured data object uses a
@typethat is not a valid schema.org type (e.g.,"@type": "BananaPhone"), the validator now returns a warning instead of silently skipping it.Changes made:
validateType()method toschemaOrg.jsto check if a type exists in the schema.org specificationvalidator.jsto always run global handlers (like schemaOrg) even when no type-specific handler is registered@typeis not a valid schema.org type withfieldName: '@type'fieldNameto property validation errors for consistencyBananaPhoneas an examplestartOffset-input) from schema.org validation testsRelated Issue
Closes #59
Motivation and Context
Previously, when a user made a typo in their schema type (e.g.,
Prodcutinstead ofProduct) or used a completely made-up type, the validator would silently skip validation without any feedback. This made it difficult for users to catch errors in their structured data. With this change, users now receive a clear warning message identifying invalid types.How Has This Been Tested?
schema:Product,https://schema.org/Product✅Screenshots (if appropriate):
N/A
Types of changes
Checklist: