Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rdb

Package Overview
Dependencies
Maintainers
1
Versions
266
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdb - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

6

.vscode/settings.json

@@ -33,5 +33,7 @@ {

},
"eslint.autoFixOnSave": true,
"eslint.alwaysShowStatus": true,
"eslint.run": "onType"
"eslint.run": "onType",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
{
"name": "rdb",
"version": "2.2.0",
"version": "2.3.0",
"main": "index.js",

@@ -24,2 +24,3 @@ "title": "rdb",

"dependencies": {
"ajv": "^6.10.2",
"deferred": "^0.7.5",

@@ -26,0 +27,0 @@ "mysql": "^2.13.0",

@@ -18,2 +18,4 @@ __rdb__

## Release notes
__2.3.0__
Added column validation with JSON Schema or plain validator.
__2.2.0__

@@ -20,0 +22,0 @@ Throw meaningful error when getById gives no match.

@@ -0,1 +1,4 @@

let Ajv = require('ajv');
let inspect = require('util').inspect;
function defineColumn(column, table) {

@@ -62,2 +65,23 @@ var c = {};

c.validate = function(value) {
column.validate = value;
return c;
};
c.JSONSchema = function(schema, options) {
let ajv = new Ajv(options);
let validate = ajv.compile(schema);
column.validate = _validate;
function _validate(value) {
let valid = validate(value);
if (!valid) {
let e = new Error(`Column ${table._dbName}.${column._dbName} violates JSON Schema: ${inspect(validate.errors, false, 10)}`);
e.errors = validate.errors;
throw e;
}
}
return c;
};
return c;

@@ -64,0 +88,0 @@ }

@@ -43,2 +43,4 @@ var updateField = require('../updateField');

this._dbRow[key] = value;
if (column.validate)
column.validate(value, this._dbRow);
updateField(table, column, this);

@@ -45,0 +47,0 @@ var emit = this._emitColumnChanged[name];

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc