A project in the Pf2ools ecosystem to define a schema for Pathfinder 2nd Edition game content. We use Zod to development the schema in TypeScript, from which we generate a mostly identical JSON Schema for general use.
Beyond providing TypeScript types for developers, the Pf2ools Schema validates JSON data for the Pf2ools ecosystem. You can validate files using this simple syntax:
npx pf2ools-schema [--options ...] <paths ...>
where <paths ...>
is one or more paths to files or directories you'd like to validate.
You can learn about the available options using npx pf2ools-schema --help
.
$ npx pf2ools-schema -ar ./myFile.json ./myDirectory
[Passed] myFile.json
[Passed] myDirectory/file1.json
[Failed] myDirectory/file2.json
[Passed] myDirectory/nestedDirectory/moreFile.json
1 file (25%) failed validation.
Using with Pf2ools Data
If you've made a local clone of the Pf2ools Data repository, you can make use of the Pf2ools Schema automatically.
First run npm i
within your cloned directory to install the latest dependencies. You can then either run npx pf2ools-schema
as above to validate something in the repo, or you can use npm run test:data
to test everything. Note that the latter might take a while, so it's not worth the effort if you're just working on a small piece!
Remember to re-run npm i
whenever the schema changes!
If your code editor supports automatic schema validation, you can point it to this file.
Alternatively, if your editor supports implicit schema validation, you can add this property to the top level of your JSON file.
"$schema": "https://raw.githubusercontent.com/Pf2ools/pf2ools-schema/master/_dist/schema/data.json"
Please see CONTRIBUTING.md
or join our Discord server for more information.
The schema and all scripts are licensed under the MIT license.