Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
json-clay
Advanced tools
JSON schema validation, fake data generation and migrations.
Weekly downloads
Readme
JSON schema validation, fake data generation and migrations.
var Clay = require('json-clay')
var person = new Clay({
schema: {
id: 'https://schema.ehealthafrica.org/1.0/person#',
$schema: 'http://json-schema.org/draft-04/schema#',
allOf: [
{
$ref: 'https://schema.ehealthafrica.org/1.0/base#'
}
],
type: 'object',
properties: {
name: {
type: 'string',
minLength: 1
}
},
required: ['name']
},
defaults: {
type: 'person',
version: '1.2.3'
}
})
person.validate({
type: 'person',
version: '1.2.3'
})
// =>
// {
// validation: {
// name: {
// required: true
// }
// }
// }
person.generate({
version: '1.0.0',
})
// =>
// {
// "type": "person",
// "version": "1.0.0"
// }
// The future:
// person.migrate({
// version: '1.0.0'
// firstName: 'Audrey',
// lastName: 'Horne'
// })
// // =>
// // [
// // {
// // version: '1.2.3'
// // name: 'Audrey Horne'
// // }
// // ]
new Clay([options])
Create a new JSON schema clay.
options.schema
- JSON schema of the clay. Default is the base schema.options.refs
- Array of referenced schemas.options.defaults
- Default properties used for generating fake data.clay.validate(json)
Validate the attribjson
against the schema.
Returns undefined
if the data is valid, otherwise an array of errors.
A typical error object looks like this:
{
validation: {
name: {
required: true
}
}
}
clay.generate([attributes])
Use this method if you want to get fake data. Utilizes
json-schema-faker.
If an attributes
object is provided, its properties will be used instead of
faked values.
Clay.schema
Holds the schema
.
Clay.refs
Holds the refs
.
Clay.defaults
Holds the defaults
.
Use it to create a simple command line utility which generates fake data:
var Clay = require('json-clay')
var cli = require('json-clay/cli')
var person = new Clay()
cli(person, process.argv.slice(2))
npm run build
Creates a browserified release in dist/json-clay.js
.
This build does not include the fake data generator.
npm test
© 2015 eHealth Systems Africa
FAQs
JSON schema validation, fake data generation and migrations.
The npm package json-clay receives a total of 1,133 weekly downloads. As such, json-clay popularity was classified as popular.
We found that json-clay demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.