0.0.4 • Published 10 years ago

partial-schema v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

partial-schema

NPM version Release Build status Test coverage Dependency Status License

Given an object and a JSON schema, generate the partial schema for that object. Used for validating partial updates

var partial = require('partial-schema');

var schema = {
  properties: {
    location: {
      type: 'object',
      required: true,
      properties: {
        lat: {
          type: 'number',
          required: true
        },
        lng: {
          type: 'number',
          required: true
        }
      }
    }
  }
};

var obj = {
  location: {
    lat: 111.11
  }
};

partial(obj, schema);
=> {
  properties: {
    location: {
      type: 'object',
      required: true,
      properties: {
        lat: {
          type: 'number',
          required: true
        }
      }
    }
  }
}
0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago