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

bookshelf-modelbase

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-modelbase - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

4

lib/index.js

@@ -20,4 +20,4 @@ var _ = require('lodash');

var validation = Joi.validate(this.attributes, this.validation);
if (validation.errors) {
throw new Error(validation.errors);
if (validation.error) {
throw new Error(validation.error);
} else {

@@ -24,0 +24,0 @@ return validation.value;

{
"name": "bookshelf-modelbase",
"version": "1.0.0",
"version": "1.1.0",
"description": "Extensible ModelBase for bookshelf-based model layers",

@@ -5,0 +5,0 @@ "main": "./lib",

@@ -1,2 +0,2 @@

ModelBase ![Build Status](https://travis-ci.org/bsiddiqui/bookshelf-modelbase.svg?branch=master) [![Code Climate](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase/badges/gpa.svg)](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase) [![Test Coverage](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase/badges/coverage.svg)](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase) [![npm version](https://badge.fury.io/js/bookshelf-modelbase.svg)](http://badge.fury.io/js/bookshelf-modelbase)
ModelBase [![Build Status](https://travis-ci.org/bsiddiqui/bookshelf-modelbase.svg?branch=master)](https://travis-ci.org/bsiddiqui/bookshelf-modelbase) [![Code Climate](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase/badges/gpa.svg)](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase) [![Test Coverage](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase/badges/coverage.svg)](https://codeclimate.com/github/bsiddiqui/bookshelf-modelbase) [![npm version](https://badge.fury.io/js/bookshelf-modelbase.svg)](http://badge.fury.io/js/bookshelf-modelbase)
==========

@@ -3,0 +3,0 @@

var Joi = require('joi');
var sinon = require('sinon');
var mocha = require('mocha');
var chai = require('chai'),
expect = chai.expect;
var chai = require('chai');
var expect = chai.expect;
var db = require('./db');
bookshelf = require('bookshelf')(db);
ModelBase = require('../lib/index')(bookshelf);
var bookshelf = require('bookshelf')(db);
var ModelBase = require('../lib/index')(bookshelf);
describe('model base', function () {
describe('modelBase', function () {
var specimen;
beforeEach(function () {
var specimenClass = ModelBase.extend({}, {
validation: {
a: Joi.string().valid('test')
}
});
specimen = new ModelBase({ name: 'hello' }, {
specimenClass = ModelBase.extend({
validation: { name: Joi.string().valid('hello') }
});
specimen = new specimenClass({ name: 'hello' });
});
describe('initialize', function () {
it('should error if not passed bookshelf object', function () {
expect(function () {
require('../lib/index')();
}).to.throw(/Must pass an initialized bookshelf instance/);
});
it('should default to any validation', function () {
specimen = new ModelBase();
expect(specimen.validation.isJoi).to.eql(true);
expect(specimen.validation._type).to.eql('any');
});
})
describe('parse', function () {

@@ -43,5 +53,9 @@ it('should convert snake case to camel case', function () {

});
});
it('should error on invalid attributes', function () {
specimen.set('name', 1);
return expect(specimen.validateSave).to.throw()
expect(function () {
specimen.validateSave();
}).to.throw(/ValidationError/);
});

@@ -48,0 +62,0 @@ });

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