partial-schema
v0.0.4
Published
Generate partial schema
Downloads
3
Readme
partial-schema
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
}
}
}
}
}