schematik

Human-friendly JSON schema

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
schematik
202.2.08 years ago9 years agoMinified + gzip package size for schematik in KB

Readme

Schematik
Circle CI Code Climate Test Coverage
Modular and human-friendly JSON schema.
Instead of writing this:
{
  "type": "number",
  "required": true,
  "minimum": -180,
  "maximum": 180,
  "exclusiveMinimum": true,
  "exclusiveMaximum": true,
  "multipleOf": 45
}
write this:
Schematik.number().in.exclusive.range.of(-180, 180).that.is.a.multiple.of(45);
or this, if you don't want to spare any keystrokes:
Schematik.number().exclusive.range(-180, 180).multiple(45);

Schematik objects are guaranteed to be immutable, therefore you can reuse them without worrying about accidental changes. For example:
const number = Schematik.number().in.range.of(10, 100);

const object = Schematik.object.with.property('foo', number.optional);
The number included in the object becomes optional, while the original number remains required.
Heavily inspired by Chai, Squel.js and lodash.

Getting Started

$ npm install schematik

After that:
Schematik = require('schematik');

var schema = Schematik.string().that.matches(/\d+/).done();
// { type: 'string', required: true, pattern: '\d+' }

Have fun!

Documentation

Please follow this link.

Testing

$ npm run test

Changes

1.0.0

- Initial Release

1.1.0

- Various Bugfixes

2.0.0

- Complete rewrite to ensure immutability. - Array.of() renamed to Array.items()

License

MIT