@gsriram24/structured-data-validator 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.eslint-header.txt +9 -0
  2. package/.releaserc.json +22 -0
  3. package/CHANGELOG.md +71 -0
  4. package/CODE_OF_CONDUCT.md +79 -0
  5. package/LICENSE +201 -0
  6. package/README.md +109 -0
  7. package/package.json +49 -0
  8. package/renovate.json +4 -0
  9. package/src/index.js +14 -0
  10. package/src/types/3DModel.js +21 -0
  11. package/src/types/AggregateOffer.js +23 -0
  12. package/src/types/AggregateRating.js +35 -0
  13. package/src/types/Answer.js +18 -0
  14. package/src/types/Article.js +26 -0
  15. package/src/types/Brand.js +18 -0
  16. package/src/types/BreadcrumbList.js +148 -0
  17. package/src/types/BroadcastEvent.js +23 -0
  18. package/src/types/Certification.js +26 -0
  19. package/src/types/Clip.js +25 -0
  20. package/src/types/DefinedRegion.js +38 -0
  21. package/src/types/Event.js +51 -0
  22. package/src/types/FAQPage.js +18 -0
  23. package/src/types/HowTo.js +27 -0
  24. package/src/types/HowToDirection.js +19 -0
  25. package/src/types/HowToSection.js +22 -0
  26. package/src/types/HowToStep.js +43 -0
  27. package/src/types/HowToTip.js +19 -0
  28. package/src/types/ImageObject.js +40 -0
  29. package/src/types/JobPosting.js +63 -0
  30. package/src/types/ListItem.js +28 -0
  31. package/src/types/LocalBusiness.js +30 -0
  32. package/src/types/MerchantReturnPolicy.js +96 -0
  33. package/src/types/Offer.js +39 -0
  34. package/src/types/OfferShippingDetails.js +27 -0
  35. package/src/types/Organization.js +18 -0
  36. package/src/types/PeopleAudience.js +37 -0
  37. package/src/types/Person.js +18 -0
  38. package/src/types/PriceSpecification.js +21 -0
  39. package/src/types/Product.js +90 -0
  40. package/src/types/ProductMerchant.js +88 -0
  41. package/src/types/QuantitativeValue.js +36 -0
  42. package/src/types/Question.js +21 -0
  43. package/src/types/Rating.js +56 -0
  44. package/src/types/Recipe.js +75 -0
  45. package/src/types/Review.js +35 -0
  46. package/src/types/SeekToAction.js +22 -0
  47. package/src/types/ShippingDeliveryTime.js +21 -0
  48. package/src/types/SizeSpecification.js +22 -0
  49. package/src/types/VideoObject.js +41 -0
  50. package/src/types/WebSite.js +23 -0
  51. package/src/types/base.js +201 -0
  52. package/src/types/schemaOrg.js +227 -0
  53. package/src/utils.js +15 -0
  54. package/src/validator.js +323 -0
@@ -0,0 +1,9 @@
1
+ Copyright {year} Adobe. All rights reserved.
2
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
3
+ you may not use this file except in compliance with the License. You may obtain a copy
4
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
5
+
6
+ Unless required by applicable law or agreed to in writing, software distributed under
7
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8
+ OF ANY KIND, either express or implied. See the License for the specific language
9
+ governing permissions and limitations under the License.
@@ -0,0 +1,22 @@
1
+ {
2
+ "branches": ["main"],
3
+ "plugins": [
4
+ "@semantic-release/commit-analyzer",
5
+ "@semantic-release/release-notes-generator",
6
+ [
7
+ "@semantic-release/changelog",
8
+ {
9
+ "changelogFile": "CHANGELOG.md"
10
+ }
11
+ ],
12
+ "@semantic-release/npm",
13
+ "@semantic-release/github",
14
+ [
15
+ "@semantic-release/git",
16
+ {
17
+ "assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
18
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
19
+ }
20
+ ]
21
+ ]
22
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,71 @@
1
+ # [1.5.0](https://github.com/adobe/structured-data-validator/compare/v1.4.1...v1.5.0) (2025-08-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add Support for Recipe and child entities ([#41](https://github.com/adobe/structured-data-validator/issues/41)) ([76c76e6](https://github.com/adobe/structured-data-validator/commit/76c76e67be7d340dd86ab790009ab488e02706f3))
7
+
8
+ ## [1.4.1](https://github.com/adobe/structured-data-validator/compare/v1.4.0...v1.4.1) (2025-08-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Handling array of contentUrls ([#39](https://github.com/adobe/structured-data-validator/issues/39)) ([77af6d5](https://github.com/adobe/structured-data-validator/commit/77af6d57b63b3cd9ed8a8244a8f263a224b4cf78))
14
+
15
+ # [1.4.0](https://github.com/adobe/structured-data-validator/compare/v1.3.0...v1.4.0) (2025-08-13)
16
+
17
+
18
+ ### Features
19
+
20
+ * Add JobPosting support ([#38](https://github.com/adobe/structured-data-validator/issues/38)) ([6523109](https://github.com/adobe/structured-data-validator/commit/652310903c7364701e065f0f0dded6ba9c619f05))
21
+
22
+ # [1.3.0](https://github.com/adobe/structured-data-validator/compare/v1.2.4...v1.3.0) (2025-08-06)
23
+
24
+
25
+ ### Features
26
+
27
+ * Added VideoObject support ([#34](https://github.com/adobe/structured-data-validator/issues/34)) ([36e863a](https://github.com/adobe/structured-data-validator/commit/36e863a34ffcc9aa80e4f6be4a5b70b8ed28f2e3))
28
+
29
+ ## [1.2.4](https://github.com/adobe/structured-data-validator/compare/v1.2.3...v1.2.4) (2025-07-31)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * Allow execution in the browser ([#31](https://github.com/adobe/structured-data-validator/issues/31)) ([159d9fb](https://github.com/adobe/structured-data-validator/commit/159d9fb1e71fc9b08d0821026bac98131fdf4f41))
35
+
36
+ ## [1.2.3](https://github.com/adobe/structured-data-validator/compare/v1.2.2...v1.2.3) (2025-07-16)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * Adjust breadcrumb position logic ([#29](https://github.com/adobe/structured-data-validator/issues/29)) ([052b443](https://github.com/adobe/structured-data-validator/commit/052b44343a2ed16546412e5d88823d0b7881de67))
42
+
43
+ ## [1.2.2](https://github.com/adobe/structured-data-validator/compare/v1.2.1...v1.2.2) (2025-07-14)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * Allow relative URLs ([#26](https://github.com/adobe/structured-data-validator/issues/26)) ([442d9b2](https://github.com/adobe/structured-data-validator/commit/442d9b2e7a0267ccedf232a2cd3513f386279aef))
49
+
50
+ ## [1.2.1](https://github.com/adobe/structured-data-validator/compare/v1.2.0...v1.2.1) (2025-07-02)
51
+
52
+
53
+ ### Bug Fixes
54
+
55
+ * Reduce requirements for nested ImageObject ([#24](https://github.com/adobe/structured-data-validator/issues/24)) ([0e17080](https://github.com/adobe/structured-data-validator/commit/0e170800a3b5fbe6debbc349ddd333dd5a4201b6))
56
+
57
+ # [1.2.0](https://github.com/adobe/structured-data-validator/compare/v1.1.0...v1.2.0) (2025-07-01)
58
+
59
+
60
+ ### Features
61
+
62
+ * Improve gtin check on Product ([#22](https://github.com/adobe/structured-data-validator/issues/22)) ([34f58e4](https://github.com/adobe/structured-data-validator/commit/34f58e4d5f92eb772f0af156d88dc1a9fd00249a))
63
+
64
+ # [1.1.0](https://github.com/adobe/structured-data-validator/compare/v1.0.0...v1.1.0) (2025-06-26)
65
+
66
+
67
+ ### Features
68
+
69
+ * Add types for Merchant Product validation ([#21](https://github.com/adobe/structured-data-validator/issues/21)) ([015cde3](https://github.com/adobe/structured-data-validator/commit/015cde3cc8c539f00c4091db7dc48c2cd876d0b2))
70
+
71
+ # Changelog
@@ -0,0 +1,79 @@
1
+ # Adobe Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our project and community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contribute to a positive environment for our project and community include:
12
+
13
+ - Demonstrating empathy and kindness toward other people
14
+ - Being respectful of differing opinions, viewpoints, and experiences
15
+ - Giving and gracefully accepting constructive feedback
16
+ - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ - Focusing on what is best, not just for us as individuals but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ - The use of sexualized language or imagery, and sexual attention or advances of any kind
22
+ - Trolling, insulting or derogatory comments, and personal or political attacks
23
+ - Public or private harassment
24
+ - Publishing others’ private information, such as a physical or email address, without their explicit permission
25
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
26
+
27
+ ## Our Responsibilities
28
+
29
+ Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any instances of unacceptable behavior.
30
+
31
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for behaviors that they deem inappropriate, threatening, offensive, or harmful.
32
+
33
+ ## Scope
34
+
35
+ This Code of Conduct applies when an individual is representing the project or its community both within project spaces and in public spaces. Examples of representing a project or community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
36
+
37
+ ## Enforcement
38
+
39
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by first contacting the project team. Oversight of Adobe projects is handled by the Adobe Open Source Office, which has final say in any violations and enforcement of this Code of Conduct and can be reached at Grp-opensourceoffice@adobe.com. All complaints will be reviewed and investigated promptly and fairly.
40
+
41
+ The project team must respect the privacy and security of the reporter of any incident.
42
+
43
+ Project maintainers who do not follow or enforce the Code of Conduct may face temporary or permanent repercussions as determined by other members of the project's leadership or the Adobe Open Source Office.
44
+
45
+ ## Enforcement Guidelines
46
+
47
+ Project maintainers will follow these Community Impact Guidelines in determining the consequences for any action they deem to be in violation of this Code of Conduct:
48
+
49
+ **1. Correction**
50
+
51
+ Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
52
+
53
+ Consequence: A private, written warning from project maintainers describing the violation and why the behavior was unacceptable. A public apology may be requested from the violator before any further involvement in the project by violator.
54
+
55
+ **2. Warning**
56
+
57
+ Community Impact: A relatively minor violation through a single incident or series of actions.
58
+
59
+ Consequence: A written warning from project maintainers that includes stated consequences for continued unacceptable behavior. Violator must refrain from interacting with the people involved for a specified period of time as determined by the project maintainers, including, but not limited to, unsolicited interaction with those enforcing the Code of Conduct through channels such as community spaces and social media. Continued violations may lead to a temporary or permanent ban.
60
+
61
+ **3. Temporary Ban**
62
+
63
+ Community Impact: A more serious violation of community standards, including sustained unacceptable behavior.
64
+
65
+ Consequence: A temporary ban from any interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Failure to comply with the temporary ban may lead to a permanent ban.
66
+
67
+ **4. Permanent Ban**
68
+
69
+ Community Impact: Demonstrating a consistent pattern of violation of community standards or an egregious violation of community standards, including, but not limited to, sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
70
+
71
+ Consequence: A permanent ban from any interaction with the community.
72
+
73
+ ## Attribution
74
+
75
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1,
76
+ available at [https://contributor-covenant.org/version/2/1][version]
77
+
78
+ [homepage]: https://contributor-covenant.org
79
+ [version]: https://contributor-covenant.org/version/2/1
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Adobe
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @adobe/structured-data-validator
2
+
3
+ ![GitHub License](https://img.shields.io/github/license/adobe/structured-data-validator)
4
+ [![CI](https://github.com/adobe/structured-data-validator/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/adobe/structured-data-validator/actions/workflows/ci.yml)
5
+ [![NPM Version](https://img.shields.io/npm/v/%40adobe%2Fstructured-data-validator?link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40adobe%2Fstructured-data-validator)](https://www.npmjs.com/package/@adobe/structured-data-validator)
6
+ ![Node Current](https://img.shields.io/node/v/%40adobe%2Fstructured-data-validator)
7
+
8
+ A JavaScript library for validating and parsing structured data according to Schema.org specifications and Google Rich Results requirements. This library ensures your structured data meets both Schema.org standards and Google's specific requirements for rich results, helping to optimize your content for search engines and other platforms.
9
+
10
+ ## Features
11
+
12
+ - Validates structured data against both Schema.org and Google Rich Results specifications
13
+ - Ensures compliance with Google's structured data guidelines
14
+ - Extensible validation system with custom type handlers
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @adobe/structured-data-validator
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ This library works in conjunction with [@marbec/web-auto-extractor](https://www.npmjs.com/package/@marbec/web-auto-extractor) to validate structured data extracted from web pages.
25
+
26
+ ```javascript
27
+ import { Validator } from '@adobe/structured-data-validator';
28
+ import WebAutoExtractor from '@marbec/web-auto-extractor';
29
+
30
+ // First, extract structured data from HTML
31
+ const extractor = new WebAutoExtractor({ addLocation: true, embedSource: ['rdfa', 'microdata'] });
32
+ const extractedData = extractor.parse(sampleHTML);
33
+
34
+ // Fetch the current schema.org schema
35
+ const schemaOrgJson = await (await fetch('https://schema.org/version/latest/schemaorg-all-https.jsonld')).json();
36
+
37
+ // Create a validator instance
38
+ const validator = new Validator(schemaOrgJson);
39
+
40
+ // Validate the extracted structured data
41
+ const results = await validator.validate(extractedData);
42
+ }
43
+ ```
44
+
45
+ The validator expects the output format from `@marbec/web-auto-extractor`, which includes:
46
+
47
+ - JSON-LD structured data
48
+ - Microdata
49
+ - RDFa
50
+
51
+ ### Browser
52
+
53
+ You can run the parser and validator directly in the browser on any website using the following commands:
54
+
55
+ ```js
56
+ const { default: WebAutoExtractor } = await import(
57
+ 'https://unpkg.com/@marbec/web-auto-extractor@latest/dist/index.js'
58
+ );
59
+ const { default: Validator } = await import(
60
+ 'https://unpkg.com/@adobe/structured-data-validator@latest/src/index.js'
61
+ );
62
+
63
+ const extractedData = new WebAutoExtractor({
64
+ addLocation: true,
65
+ embedSource: ['rdfa', 'microdata'],
66
+ }).parse(document.documentElement.outerHTML);
67
+ console.log(extractedData);
68
+ const schemaOrgJson = await (
69
+ await fetch('https://schema.org/version/latest/schemaorg-all-https.jsonld')
70
+ ).json();
71
+ await new Validator(schemaOrgJson).validate(extractedData);
72
+ ```
73
+
74
+ ## Development
75
+
76
+ ### Prerequisites
77
+
78
+ - Node.js (latest LTS version recommended)
79
+ - npm
80
+
81
+ ### Setup
82
+
83
+ 1. Clone the repository
84
+ 2. Install dependencies:
85
+ ```bash
86
+ npm install
87
+ ```
88
+
89
+ ### Available Scripts
90
+
91
+ - `npm test` - Run tests with coverage
92
+ - `npm run lint` - Run ESLint
93
+ - `npm run format` - Check code formatting
94
+ - `npm run format:fix` - Fix code formatting issues
95
+
96
+ ### Debug Logging
97
+
98
+ To enable debug logging and see detailed validation output, set the `debug` property to `true` on your `Validator` instance:
99
+
100
+ ```js
101
+ const validator = new Validator();
102
+ validator.debug = true; // Enable debug logging
103
+ ```
104
+
105
+ This will print additional information to the console during validation, which is useful for development and troubleshooting.
106
+
107
+ ## Dependencies
108
+
109
+ - [@marbec/web-auto-extractor](https://www.npmjs.com/package/@marbec/web-auto-extractor) - For extracting structured data from web pages
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@gsriram24/structured-data-validator",
3
+ "version": "1.6.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Structured Data Validator",
8
+ "type": "module",
9
+ "main": "src/index.js",
10
+ "scripts": {
11
+ "test": "npm run lint && npm run format && npm run unit-test",
12
+ "unit-test": "c8 mocha --recursive 'src/**/*.test.js'",
13
+ "lint": "eslint 'src/**/*.js'",
14
+ "format": "prettier --single-quote --check .",
15
+ "format:fix": "prettier --single-quote --write .",
16
+ "semantic-release": "semantic-release",
17
+ "semantic-release-dry": "semantic-release --dry-run --no-ci --branches $CI_BRANCH"
18
+ },
19
+ "keywords": [],
20
+ "engines": {
21
+ "node": ">=18.0.0"
22
+ },
23
+ "author": "Adobe",
24
+ "license": "Apache-2.0",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/gsriram24/structured-data-validator.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/gsriram24/structured-data-validator/issues"
31
+ },
32
+ "devDependencies": {
33
+ "@eslint/js": "^9.22.0",
34
+ "@marbec/web-auto-extractor": "^2.1.0",
35
+ "@semantic-release/changelog": "^6.0.3",
36
+ "@semantic-release/git": "^10.0.1",
37
+ "@semantic-release/github": "^11.0.2",
38
+ "@semantic-release/npm": "^12.0.1",
39
+ "c8": "^10.1.3",
40
+ "chai": "^5.2.0",
41
+ "eslint": "^9.22.0",
42
+ "eslint-plugin-headers": "^1.2.1",
43
+ "globals": "^16.0.0",
44
+ "mocha": "^11.1.0",
45
+ "prettier": "^3.5.3",
46
+ "semantic-release": "^24.2.4",
47
+ "sinon": "^21.0.0"
48
+ }
49
+ }
package/renovate.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": ["config:recommended"]
4
+ }
package/src/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import { Validator } from './validator.js';
13
+
14
+ export default Validator;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import BaseValidator from './base.js';
13
+
14
+ export default class ThreeDModelValidator extends BaseValidator {
15
+ getConditions() {
16
+ return [
17
+ this.required('encoding'),
18
+ this.required('encoding.contentUrl', 'url'),
19
+ ].map((c) => c.bind(this));
20
+ }
21
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import BaseValidator from './base.js';
13
+
14
+ export default class PriceSpecificationValidator extends BaseValidator {
15
+ getConditions() {
16
+ return [
17
+ this.required('lowPrice', 'number'),
18
+ this.required('priceCurrency', 'currency'),
19
+ this.recommended('highPrice', 'number'),
20
+ this.recommended('offerCount', 'number'),
21
+ ].map((c) => c.bind(this));
22
+ }
23
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2025 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import RatingValidator from './Rating.js';
13
+
14
+ export default class AggregateRatingValidator extends RatingValidator {
15
+ getConditions() {
16
+ const conditions = super.getConditions();
17
+
18
+ conditions.push(
19
+ this.or(
20
+ this.required('ratingCount', 'number'),
21
+ this.required('reviewCount', 'number'),
22
+ ),
23
+ );
24
+
25
+ // If not embedded into other type, itemReviewed is required
26
+ if (this.path.length === 1) {
27
+ conditions.push(
28
+ this.required('itemReviewed'),
29
+ this.required('itemReviewed.name'),
30
+ );
31
+ }
32
+
33
+ return conditions.map((c) => c.bind(this));
34
+ }
35
+ }