Name: schemas
Owner: ZEIT
Description: All schemas used for validation that are shared between our projects
Created: 2018-05-16 10:03:45.0
Updated: 2018-05-17 05:30:17.0
Pushed: 2018-05-24 09:06:38.0
Homepage: https://npmjs.com/@zeit/schemas
Size: 26
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The schemas contained within this package are used all across the ZEIT ecosystem to validate config files, requests to APIs and more. It ensures users always send just the right data.
It is important that these schemas stay in sync between projects, so that the validations are always performed in the same way for the same kind of object.
The files located in this repository are .js
and not .json
, because parsing JSON takes a little bit longer.
To get started, pick one of the schemas in this repository and load it:
t schema = require('@zeit/schemas/deployment/config');
Next, set up AJV (the validator) and run the schema through it:
t AJV = require('ajv');
t ajv = new AJV({ allErrors: true });
t isValid = ajv.validate(schema, <object-to-validate>);
!isValid) {
console.error(`The following entries are wrong: ${JSON.stringify(ajv.errors)}`);
That is all! :tada:
npm link
@zeit/schemas
, just link it to the dependencies: npm link @zeit/schemas
and load it!Leo Lamprecht (@notquiteleo) - ZEIT