grunt-jsonschema

Simple and fast JSON schema validator for grunt.

grunt-jsonschema v0.0.4

Simple and fast JSON schema validator for grunt.

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-jsonschema --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-jsonschema');

In your project's Gruntfile, add a section named jsonschema to the data object passed into grunt.initConfig().

grunt.initConfig({
  jsonschema: {
    options: {
      file: 'test/files/person.json',
      schema: 'test/schemas/person.json'
    }
  }
});

Type: String Default value: null

path to json file that wants to be validated.

Type: String Default value: null

jsonschema path.

grunt.initConfig({
  jsonschema: {
    all:{
      options: {
        file: 'test/files/person.json',
        schema: 'test/schemas/person.json'
      }
    }
  }
});
grunt.initConfig({
  jsonschema: {
    all:{
      options: {
        files: [
          {
            file: 'test/files/person.json',
            schema: 'test/schemas/person.json'
          },
          {
            file: 'test/files/posts.json',
            schema: 'test/schemas/posts.json'
          }
        ]
      }
    }
  }
});
grunt.initConfig({
  jsonschema: {
    all:{
      options: {
        schema: 'test/schemas/person.json',
        files: [
          'test/files/person.json',
          'test/files/person2.json'
        ]
      }
    }
  }
});
grunt.initConfig({
  jsonschema: {
    all:{
      options: {
        file: 'test/files/person.json',
        schema: {
          main: 'test/schemas/person_ref.json',
          refs: [
            'test/schemas/address.json'
          ]
        }
      }
    }
  }
});
grunt.initConfig({
  jsonschema: {
    all:{
      options: {
        files: [
          'test/files/person.json',
          'test/files/person2.json'
        ],
        schema: {
          main: 'test/schemas/person_ref.json',
          refs: [
            'test/schemas/address.json'
          ]
        }
      }
    }
  }
});

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.