2.2.0 • Published 8 years ago

schematik v2.2.0

Weekly downloads
385
License
MIT
Repository
github
Last release
8 years ago

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

2.2.0

8 years ago

2.1.0

8 years ago

2.0.2

8 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago