json-schema-validator-async
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

json-schema-validator-async

An async JSON schema validator compatible with $ref file dependencies and angular 2+ karma

How to integrate with angular 2+ and karma

  • expose json folder by updating the file karma.conf.js
...
files: [
  ...
  { pattern: 'schemas/*.json', server: true, included: false, watched: true}
  ...
],
...
  • use it in the .spec.ts:
import { JsonSchemaValidator } from 'json-schema-validator-async';
schema1Validator = new JsonSchemaValidator({path: 'base/schemas/*.json', mainSchemaFile: 'resourceSchema.json'});
...
it('shoud have the valid schema' (done) => {
  jsonData = {...};
  schema1Validator.validate(jsonData, expect).then(done, done);
});

Note that the path has the prefix base/. Also note that async function is not trully async, done method does the best job.

On fail you will see the errors json.

Dependencies (1)

Dev Dependencies (17)

Package Sidebar

Install

npm i json-schema-validator-async

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • ionlupascu