npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@typhonjs-fvtt/validate-manifest

v8.0.0

Published

Provides validation functions / JSON schemas for FVTT module / system manifests & manifest+ extensions.

Downloads

6

Readme

@typhonjs-fvtt/validate-manifest

NPM Code Style License

Build Status Coverage Dependency Status

Providing JSON schemas for Foundry VTT module.json / system.json manifests & League of Extraordinary Foundry Developers manifest+ extensions in addition to compiled validator functions. The current manifest+ support is v1.1.0.

There are loose and strict variations for the four schema variations. Loose variations follow the officially posted manifest and manifest plus specifications and only check that types are correct. The strict variations enforce extra rules such as semantic versioning where applicable and other pattern matching aspects to ensure correctness.

JSON Schema / IDE integration

For end developers it is useful to set up the appropriate JSON schema with your IDE. Check these links for IDE info for Webstorm or
VS Code. Point to the relevant JSON schema file found in ./schema and enable intellisense in your IDE. For reference since this is a NPM module you will link ./node_modules/@typhonjs-fvtt/validate-manifest/schema/strict/module+.json. The schema files ending in + include the standard manifest and manifest plus coverage.

There are 8 schemas available:

  • ./schema/loose/module.json
  • ./schema/loose/module+.json
  • ./schema/loose/system.json
  • ./schema/loose/system+.json
  • ./schema/strict/module.json
  • ./schema/strict/module+.json
  • ./schema/strict/system.json
  • ./schema/strict/system+.json

Foundry VTT tools developers

For Foundry VTT tools developers and anyone needing to validate manifest files. The validator functions are compiled by ajv and are located in the ./dist directory. The main entry point for the NPM module points to the ./dist/validators.js.

There are 8 validator functions:

  • validateModule
  • validateModuleStrict
  • validateModulePlus
  • validateModulePlusStrict
  • validateSystem
  • validateSystemStrict
  • validateSystemPlus
  • validateSystemPlusStrict

A trivial example of using the validateModule function.

import fs                 from 'fs';

import { validateModule } from '@typhonjs-fvtt/validate-manifest';

const moduleJSONObject = JSON.parse(fs.readFileSync('./src/module.json', 'utf8'););  // load from some location.

if (!validateModule(moduleJSONObject))
{
  console.log(JSON.stringify(validateModule.errors);
}

Please see ajv and ajv-errors for more information about the validator functions and resulting error entries stored in the errors array after a validator function is invoked. Considerable work has been done to ensure that one condition resolves to one error listed in the errors array. There is a comprehensive test suite which covers all possible errors that may occur with data contained in the manifest files.

If you are planning on displaying error information to end users you may want to take a look at the @typhonjs-node-utils/better-ajv-errors module which formats the errors array with user readable messages and associated code frames. An example of using the better-ajv-errors module.

import fs                 from 'fs';

import BetterErrors       from '@typhonjs-node-utils/better-ajv-errors';
import { validateModule } from '@typhonjs-fvtt/validate-manifest';

const moduleJSONFile = fs.readFileSync('./src/module.json', 'utf8');   // load the text string for the manifest.
const moduleJSONObject = JSON.parse(moduleJSONFile);                   // parse the manifest file.

if (!validateModule(moduleJSONObject))
{
   console.log(BetterErrors.asString(validateModule.errors, { file: moduleJSONFile }));
}

###Architecture A very brief overview... The base source schemas is shared across all variations and located in ./src/schema and is compiled / dereferenced into single file loose and strict variations in ./schema by the compile NPM script. There is a custom merge step with template includes found in ./src/schema/merge. These are common definitions which are then combined into the final schema files.

Please reach out and get in touch if you need any more assistance at the issues forum.