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

fluid-json-schema

v2.1.7

Published

Support validation of JSON within the Fluid ecosystem.

Downloads

12

Readme

fluid-json-schema

What is this?

JSON Schemas are JSON documents that describe how a JSON object should be structured. The JSON Schema standard includes rules about what fields are required, what type and format of data is allowed in a field, and many other complex rules that allow you to do things like limit the length of a text field, or require between one and three entries in an array.

This package provides a series of Fluid components and static functions that are intended to help with two general use cases:

  1. Defining the fields and values that are allowed in JSON using FSS, a variant of the underlying JSON Schema language.
  2. Validating JSON data against an FSS Schema and reporting errors to the user. See the validator documentation for more details.

Although you can reuse the above in various additional ways, this package provides components and functions to assist with the following specific use cases:

  1. (In both Node and a browser) Defining the information a schema-validated component requires to start up and preventing its creation if material is missing or incorrect.
  2. (In both Node and a browser) Defining what is allowed in the model of a schema-validated modelComponent, and automatically (re)validating the model when changes are made.
  3. (In Node) Rejecting invalid data sent to a REST endpoint (presumably via a POST or PUT request) served up by either fluid-express or kettle. See the middleware documentation for more details.
  4. (In a browser) Associating model material with HTML DOM elements, and displaying validation errors in context using the "error binder".

Running the tests

You can run the tests on a local machine using commands like the following from the root of the repository:

npm install
npm test

Running the Browser Tests without Instrumentation

By default, the browser tests are run against instrumented code so that we can prepare a code coverage report at the end of each test run. If you need to troubleshoot a problem with the browser tests, you can also run the tests against the raw source code by hosting the content in a standalone web server and then opening the tests in a browser. For example, if you have python installed, you can use the command python -m SimpleHTTPServer from the root of the repository, and then open http://localhost:8000/tests/browser-fixtures/all-tests.html in a browser.

Using these components in a browser

This package depends on AJV. AJV can be used on the client-side, but must first be bundled using browserify. The AJV package takes care of this automatically when it's installed, the required client-side bundle can be found in ./node_modules/ajv/dist/ajv.bundle.js once you've installed this package's dependencies. The remaining client-side dependencies depend on which parts of this package you're using. See the HTML browser test fixtures in ./tests/static/ for examples.