Socket
Book a DemoInstallSign in
Socket

validate-schema

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate-schema

validate objects against redshift schema definitions

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

validate-schema

Validate an object against a schema.

Installation

$ npm install validate-schema

Example

var validate = require('validate-schema');
var generate = require('auto-schema');

var schema = generate({
  user: {
    id: 123242123,
    name: {
      first: 'tobi',
      last: 'loki'
    }
  }
});

console.log();
console.log(schema);

var obj = {
  user: {
    id: '1234123',
    name: {
      first: 'tobi',
      last: 123
    },
    timestamp: 1394646734792
  }
};

console.log();
console.log(validate(obj, schema));

yields:

{ 'user.id': 'float',
  'name.first': 'varchar',
  'name.last': 'varchar' }

{ 'user.id': 'number expected',
  'name.last': 'string expected',
  'user.timestamp': 'undefined column' }

License

MIT

Keywords

redshift

FAQs

Package last updated on 12 Mar 2014

Did you know?

Socket

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.

Install

Related posts